Jump to content
IGNORED

2011 Nukey Hack Code for Adventure


keithbk

Recommended Posts

Back in 2011, Nukey had worked up an idea I had for a possible future Adventure-style game that included the concept of an "overhead" game map. In this version, just south of the gold castle, was a teleport that would take you to a map that would transport you to other areas. Conceptually, I was playing around at developing a multi-region environment (a complete game world), but I never completed my work on the project and the project languished in developmental oblivion.

 

So, here's the code for you to play with. You can test this code online at 8bitworkshop: https://8bitworkshop.com/v3.4.2/?file=examples%2Fhello.a&platform=vcs

 

This is pretty much Nukey's code, and he may have published it elsewhere, but in the off chance he did not, someone should have the benefit of learning from it:

 

 

 


;ADVENTURE: 8K/16K/32K multicolor sprite & playfield hack by Kurt (Nukey Shay) Howe, 3/09/2011
 
;Test options...
TEST_MAP           = 1
IGNORE_WALLS       = 0  ;1 = player can move any direction through walls
IGNORE_DOT         = 0  ;1 = allow passage through right panels without dot or objects
IGNORE_LEFT_PANELS = 0  ;1 = allow passage through left panels
TEST_SEED          = 0  ;1 = check the random generator...uses next constant as seed value
SEED               = $0F ;value $0F should produce a game that only has bat & magnet present
 
 
;Size of binary to produce...
BANKS              = 0 ;0 = 8K (F8), 1 = 16K (F6), 2 = 32K (F4)
 
 
;Region options...
PAL                = 0 ; 0 = Use NTSC color palette, 1 = Use PAL color palette
PAL50              = 0 ; 0 = Display 262 scanlines @60hz, 1 = Display 312 scanlines 50hz
 
 
;Randomization options...
FIX_RANDOM         = 0  ;1 = regroup castle interiors to end of list
RANDOM_XY          = 1  ;1 = alter starting X/Y of game objects in random game selection(s)
 
 
;Gameplay options...
ANIMATE_DRAGON      = 0 ;1 = use 2 frames for roaming dragon
FLIP_DRAGONS        = 1 ;1 = have dragons face the player when chasing
ROTATING_SWORD      = 1 ;1 = move sword around player as it's carried
BAT_REVIVES_DRAGONS = 0 ;1 = dead dragon will be alive again if bat picks it up
EDGE_PANELS         = 1 ;1 = place panels closer to the screen border
BW_PAUSE            = 1 ;1 = allow B&W switch to pause gameplay indefinately
NO_TRAP             = 0 ;1 = impossible to intentionally lock keys in their own castles
MERGE_STICKS        = 1 ;0 = left stick only, 1 = use either stick
 
 
;Game kernel options...
COLOR_DELIMITER     = 0 ;constant, signifies end of bitmap...must be zero
USE_TITLE_DISPLAY   = 1 ;1 = use a special screen for game selection
TITLE_BANK          = 0 ;Bank number if the above is used (just put Titlescreen anywhere)
MAP_BANK            = 0 ;Bank number if the above is used (just put Titlescreen anywhere)
 
MONOCOLOR           = 1 ;set to 1 if any bank uses the monocolor playfield kernel
MULTICOLOR          = 0 ;set to 1 if any bank uses the multicolor playfield kernel
 
 
USE_UNIQUE_BACKGROUND_COLORS = 0 ;1 = use seperate colors for each screen's background (floor)
FLASH_WALLS                  = 1 ;set to 1 if winning flashes the playfield
FLASH_GROUND                 = 0 ;set to 1 if winning flashes the background
SIMULATE_CHALISE_FLASH       = 1 ;1 = use multiple states for the chalise
UNROLL_SUBS         = 1 ;set to 1 to avoid collision subroutines (costs romspace in last bank)
UNROLL_POSITIONING  = 1 ;set to 1 to avoid sprite repositioning as a subroutine (costs rom)
 
 
  IF PAL50
TIME1        = $3F
TIME2        = $4F
ONE_PIXEL    = $01
TWO_PIXELS   = $03
THREE_PIXELS = $04
  ELSE
TIME1        = $20
TIME2        = $32
ONE_PIXEL    = $01
TWO_PIXELS   = $02
THREE_PIXELS = $03
  ENDIF
 
 
      processor 6502
 
;2600's hardware equates...
VSYNC   =  $00
VBLANK  =  $01
WSYNC   =  $02
NUSIZ0  =  $04
NUSIZ1  =  $05
COLUP0  =  $06
COLUP1  =  $07
COLUPF  =  $08
COLUBK  =  $09
CTRLPF  =  $0A
REFP0   =  $0B
REFP1   =  $0C
PF0     =  $0D
PF1     =  $0E
PF2     =  $0F
RESP0   =  $10
RESP1   =  $11
RESBL   =  $14
AUDC0   =  $15
AUDC1   =  $16
AUDF0   =  $17
AUDF1   =  $18
AUDV0   =  $19
AUDV1   =  $1A
GRP0    =  $1B
GRP1    =  $1C
ENAM0   =  $1D
ENAM1   =  $1E
ENABL   =  $1F
HMP0    =  $20
HMP1    =  $21
HMBL    =  $24
VDELBL  =  $27
HMOVE   =  $2A
HMCLR   =  $2B
CXCLR   =  $2C
Waste2  =  $2E   ; invalid ram location used to waste cycles
CXP0FB  =  $32   ; Player0 - Ball collisions
CXP1FB  =  $33   ; Player1 - Ball collisions
CXM0FB  =  $34   ; Missile0 - Ball collisions
CXM1FB  =  $35   ; Missile1 - Ball collisions
CXBLPF  =  $36   ; Ball - Playfield collisions
CXPPMM  =  $37   ; Player0 - Player1 collisions
INPT4   =  $3C   ; Left joystick trigger
INPT5   =  $3D   ; Right joystick trigger
SWCHA   =  $0280 ; Joystick direction
SWCHB   =  $0282 ; Console switches
INTIM   =  $0284
TIM64T  =  $0296
 
       SEG.U variables
       ORG $80
 
;game engine variables...
Obj1Lo        DS 2 ; Indirect pointer of object 1...must remain unchanged between frames
Obj1Hi        = Obj1Lo+1
Obj2Lo        DS 2 ; Indirect pointer of object 2...must remain unchanged between frames
Obj2Hi        = Obj2Lo+1
Obj1Y         DS 1 ; Vertical position of object 1 (must remain unchanged for 3 frames)
Obj2Y         DS 1 ; Vertical position of object 2 (must remain unchanged for 3 frames)
NoteCnt       DS 7 ; Game Reset restores these 7 bytes in a loop.
PlayerRoom    = NoteCnt+1 ; Current display variables
PlayerX       = NoteCnt+2
PlayerY       = NoteCnt+3
PrevRoom      = NoteCnt+4 ; Previous display variables (needed for post-collision corrections)
PrevX         = NoteCnt+5
PrevY         = NoteCnt+6
CurrentObject DS 4 ; This must be 4 consecutive bytes
CurrentStick  DS 1 ; Upper nybble = stick, bit2 = B&W toggle, bit 0/1,3 = console switch
LastObj       DS 1 ; Pointer to the list of printable objects (unsharable)
ObjDir        DS 1 ; Current direction of player/AI object being dealt with
ObjAddress    DS 1 ; Current object's dynamic data pointer...also used as portcullis number
ObjLst        DS 2 ; Used as an indirect pointer
Delta2        DS 2 ; Delta2 & 1 also used as the indirect ball sprite pointer
Delta1        = Delta2+1
ObjCr         DS 1 ; Sharable...used to match current object
Level         DS 1 ; Bit0 = console type, bit3-1 = game selection, upper nybble = game sound
Control       DS 1 ; Bit7=inactive game, bits6-0 = room # backup (for printing)
Index1        DS 1 ; Object # of "liked" object (sharable?)
LoCnt         DS 1 ; Bumped once after 3 display frames (rollover @ 768/60 = 12.8 seconds)
HiCnt         DS 1 ; Bumped upon LoCnt rollover.  When high bit set, "attract mode" is enabled
                   ; Bit0 of HiCnt = flag to display game select screen
ObjectNumber  DS 1 ; Current object # of sprite being dealt with
Temp          DS 1 ; General purpose ram
CarriedObj    DS 3 ; All 3 must be consecutive
CarriedX      =  CarriedObj+1
CarriedY      =  CarriedObj+2
 
;Object variables...
SurroundR     DS 3 ;(3 bytes)
MapPortR      DS 3 ;(3 bytes)
DotR          DS 3 ;(3 bytes) NOTE: should be the first movable object in RAM
;NOTE: all dragons must be consecutive
RDragonR      DS 5 ;(5 bytes)
YDragonR      DS 5 ;(5 bytes)
GDragonR      DS 5 ;(5 bytes)
MagnetR       DS 3 ;(3 bytes)
SwordR        DS 3 ;(3 bytes)
ChalliseR     DS 3 ;(3 bytes)
BridgeR       DS 3 ;(3 bytes)
;NOTE: all keys must be consecutive
YKeyR         DS 3 ;(3 bytes)
WKeyR         DS 3 ;(3 bytes)
BKeyR         DS 3 ;(3 bytes)
;NOTE: all gates must be consecutive
YGateR        DS 1
WGateR        DS 1
BGateR        DS 1
BatR          DS 6 ;(6 bytes)
  IF ROTATING_SWORD
SwordState    DS 1 ;sword rotation
  ENDIF
 
 
;-------------------------------------------------------------------------------
;Ram locations D8-FB free (FC/FF used by the stack...subroutines nested 2 levels)
;-------------------------------------------------------------------------------
 
 
;Shared variables used in the kernel (sharing temp ram used by the main program)
RoomDefIndex  =  ObjCr
RoomLo        =  ObjLst    ; RoomLo/Hi pushed to the stack prior to kernel execution, & pulled
RoomHi        =  ObjLst+1  ; Back when returning (leaves a 2-byte margin for nesting subs)
PixelCount    =  CurrentObject+1
NextPF0       =  ObjAddress
NextPF1       =  Temp
NextPF2       =  CurrentObject
NextCount     =  ObjDir
NextCOLUPF    =  ObjectNumber
Ball          =  Delta2
 
;Shared variables used by the main program:
NullR         =  BridgeR
Sound         =  Level       ;Upper nybble of the Level variable
ObjX          =  Delta2      ;Used only during object setup
MagSave       =  Delta1      ;Used for saving/restoring magnet Y position in it's subroutine
BatStateBackup = Obj2Hi
 
 
;Constants...
;Object numbers...these are used to calculate the offsets of the object table
;"Passthru" objects...
NullNumber     =  NullData - Object_Data_LSB     ;($00)
SurroundNumber =  SurroundData - Object_Data_LSB ;($12)
LastPassNumber =  SurroundNumber ;(last object that allows you to walk into w/no collision!)
MapPortNumber  =  MapPortData - Object_Data_LSB  ;
;"Solid" objects...
YGateNumber    =  YGateData - Object_Data_LSB    ;($01)
WGateNumber    =  WGateData - Object_Data_LSB    ;($02)
BGateNumber    =  BGateData - Object_Data_LSB    ;($03)
AuthorNumber   =  AuthorData - Object_Data_LSB   ;($04)
  IF USE_TITLE_DISPLAY = 0 ;seperate level-select screen doesn't use the number tokens
NumberNumber   =  NumberData - Object_Data_LSB   ;($05)
  ENDIF
RDragonNumber  =  RDragonData - Object_Data_LSB  ;($06)
YDragonNumber  =  YDragonData - Object_Data_LSB  ;($07)
GDragonNumber  =  GDragonData - Object_Data_LSB  ;($08)
SwordNumber    =  SwordData - Object_Data_LSB    ;($09)
BridgeNumber   =  BridgeData - Object_Data_LSB   ;($0A)
YKeyNumber     =  YKeyData - Object_Data_LSB     ;($0B)
WKeyNumber     =  WKeyData - Object_Data_LSB     ;($0C)
BKeyNumber     =  BKeyData - Object_Data_LSB     ;($0D)
BatNumber      =  BatData - Object_Data_LSB      ;($0E)
DotNumber      =  DotData - Object_Data_LSB      ;($0F)
ChalliseNumber =  ChalliseData - Object_Data_LSB ;($10)
MagnetNumber   =  MagnetData - Object_Data_LSB   ;($11)
LastObjectNumber =  MagnetNumber
 
 
;RD0 used to calculate map direction value when including differences
RD0            =  Level1Diffs - $80
 
;the number of castle gates...
Gates          =  $02 ;# of castle gates - 1
 
;Winning game screen (where to bring the challise)
WinRoom        =  <(Rm12-Rm00) ;(Yellow Castle's room number)
 
;Game setup...
ByteNum        =  Game2Objects - (Game1Objects+1) ;number of bytes in each "fill" table
RndNum         =  Object_Map_Tbl-(Room_Bounds_Tbl+3) ; offset value for the room bounds table
RndMax         =  $1F ;Mask for the upper bounds of the random seed
;NOTE: to allow objects to be placed in more than 32 rooms, alter this to be $3F for a maximum
;      of 64 rooms, or $7F for a maximum of 128 rooms.  Using $FF for 256 rooms is possible
;      only if the RoomDiffs method is altered or removed.
 
 
;height of magnet object (used to adjust attracted object)
MAGNET_HEIGHT = (GfxMagnetEnd - GfxMagnet)/2
 
 
;alternate use of room GFX pointer MSB's upper 3 bits...
BANK0          =  %00000000 ; room gfx exists in first bank   (irrelevant for 8K)
BANK1          =  %00100000 ; room gfx exists in second bank  (irrelevant for 8K)
BANK2          =  %01000000 ; room gfx exists in third bank   (irrelevant for 8K)
  IF BANKS = 2
BANK3          =  %01100000 ; room gfx exists in fourth bank  (irrelevant for 8K/16K)
BANK4          =  %10000000 ; room gfx exists in fifth bank   (irrelevant for 8K/16K)
BANK5          =  %10100000 ; room gfx exists in sixth bank   (irrelevant for 8K/16K)
BANK6          =  %11000000 ; room gfx exists in seventh bank (irrelevant for 8K/16K)
  ELSE
BANK3          =  %00000000 ; force invalid banks to be first bank
BANK4          =  %00000000 ; .
BANK5          =  %00000000 ; .
BANK6          =  %00000000 ; .
  ENDIF
 
SURROUND       =  %00010000 ; display the "surround" sprite. Playfield priority is suggested
 
;Used to merge sprite size with MSB table...
SIZE0  =  %00000000 ;1x width
SIZE1  =  %00100000 ;Two copies-close
SIZE2  =  %01000000 ;Two copies-medium
SIZE3  =  %01100000 ;Three copies-close
SIZE4  =  %10000000 ;Two copies-wide
SIZE5  =  %10100000 ;2x width
SIZE6  =  %11000000 ;Three copies-medium
SIZE7  =  %11100000 ;4x width
 
;set value to use in bankswitch AND# instruction
  IF BANKS
BANK_SELECT = (BANKS * 2)-1 ;16K = 3, 32K = 7
  ELSE
BANK_SELECT = 0             ;8K = 0
  ENDIF
 
;low nybble of PF0 data...
REV   =  %0001 ; bit position to (R)everse playfield
LP    =  %0010 ; bit position to activate left-hand panels (missile0)
HIDE  =  %0100 ; bit position to give playfield priority (i.e. hide sprite objects)
RP    =  %1000 ; bit position to activate right-hand panels (missile1)
 
 
 
 
 
;This section defines the display kernel and object bitmaps that remain the same in all three
;display banks.  If you want an object to differ in appearance depending on which bank you are
;in, it would be necessary to remove it from the macro and have the bitmap present in any bank
;that it is allowed to appear in AT THE SAME ADDRESS in each bank.
;     If you have no clue about what this means, just add your object bitmaps *in* the
; Object_Bitmaps macro (i.e. above the ENDM line), and keep your room GFX *out of* the macro.
;
;Using multicolor sprite objects:
;      Sprite definitions must begin with a zero value (to handle cases where the object is not
;     at the top of the screen).  The color value immediately following this zero value does
;     not matter...as long as it's not zero (if color = zero, end of bitmap reached).  If the
;     black color is needed anywhere in the sprite, just use value $01.  Also, because the loop
;     always draws sprite info no matter what, the bitmap value immediately preceding the zero
;     color must be zero as well (to erase the sprite when the drawing has finished).
;      Because the sprite definition MUST begin with zero, and MUST end with zero, you could
;     run one bitmap directly into another using a single zero value both as the end of the
;     first bitmap, and the beginning gfx of the next.  See the dot bitmap below for an example
;     of running sprites together to save 1 byte for each case.
;      The "Null" object needs no bitmap values...and can be located at any double-zero data.
;     Sprite objects are allowed to extend right to the end of a page (i.e. Delimiter placed
;     at $xxFF)...but any single sprite definition must not cross any page boundries.
;
;ROOM GRAPHICS DATA DESCRIPTION -
;   Monocolor_Display_Kernel2 uses this data layout for each band of playfield graphics:
;     .byte PF0|CTRL,PF1,PF2,LINES       ;4 bytes per band
;   Multicolor_Display_Kernel2 uses this data layout for each band of playfield graphics:
;     .byte COLOR,PF0|CTRL,PF1,PF2,LINES,{2nd color, 3rd color, etc} ;5+ bytes per band
;     The intro color value must be an even value (bit0 = off), but any additional color
;     values for that band of gfx must be an odd value (bit0 = on).
;
;   Caching / Page crossing of PF data:
;      Before display, room data is cached in temp memory (this does not rob from available
;      user ram), so that it is accessed much quicker when actually needed.
;
;      Monocolor_Display_Kernel2 will automatically adjust room pointers to next page should
;      the caching routine notice that less than 4 bytes currently exist before an upcoming
;      page break...and will skip 3, 2, or 1 bytes accordingly
;
;      Multicolor_Display_Kernel2 will also adjust pointers for page breaks...but ONLY when
;      the routine is updating the current band's color (so you should align data so that page
;      breaks only happen between full definition lines...and set bit0 in remaining bytes).
;      Take note that the rest of the caching routine is SKIPPED when a band's color is being
;      adjusted, so the number of times you can REcolor a band is limited to LINES-2 (the
;      initial color being set by the first byte, and a 1-scanline margin to allow caching of
;      the next band.
;
;   Playfield control:
;     The high nybble of the first byte in each band is the bitpattern used for PF0 gfx
;     Lower nybble description:
;     "REV"  Bit0 (+$01) true if (R)eversed playfield
;     "LP"   Bit1 (+$02) true if left panel wanted
;     "HIDE" Bit2 (+$04) true if playfield has priority over sprites (dark rooms, hide sprites)
;     "RP"   Bit3 (+$08) true if right panel wanted
;
;   NOTE:
;    In 16/32k build, you can use differing kernels depending on how you want the gfx displayed
;   for room definitions present in that bank - cycle timing is identical leading into and out
;   of either kernel back to the main program.  Any sprite definitions confined to those rooms
;   must at least be present in the bank where the room graphics exists (i.e. free-roaming or
;   carriable sprites should probably be present in all banks...but the number tokens and the
;   author signature sprites need only be present in banks that include the game-select and
;   signature rooms...respectively).  Similarly, the "surround" sprite must be present in any
;   bank that features "dark" rooms...but not needed in any bank that has no dark rooms.  This
;   strategy saves space in any bank that does not call for such objects to be present.  To do
;   this with any sprite object, just remove it from the Object_Bitmaps macro and paste it
;   directly into one of the banks/pages below.
;
;   Ball enable:
;    To save time, the ball is updated by using the current scanline count as an indirect
;   pointer to a large, 201-byte display table.  This table's values are currently only using
;   bit1...and can be shared with other data that does not need that bit.  The table can be
;   relocated if desired...although as with any other sprite data, it must not cross a page
;   boundry.  To relocate, just remove the Ball_Enable_Table macro call from the end of bank
;   data (and move the tag BallGFX wherever you want).  In this way, you can save 201 bytes in
;   each bank if you have at least that number of consecutive bytes with bit1 unused in movable
;   object sprite data.  Keep in mind that a 4-byte stretch must have bit1 enabled at 93 bytes
;   into the table, with all the rest turned off.
 
 
 
       SEG Macros
 
  MAC CHECKPAGE
    IF >. != >{1}
      ECHO ""
      ECHO "ERROR: different pages! (", {1}, ",", ., ")"
      ECHO ""
      ERR
    ENDIF
  ENDM
 
  MAC Monocolor_Display_Kernel2
    IF BANKS = 2
       lda    $FFFB               ;4
       jmp    StartGame           ;3 Go to cold start routine in last bank
      IF USE_TITLE_DISPLAY
TitleDone: ;65
       lda    $FFFB               ;4 69 Select last bank
       jmp    TitleKernel         ;3
MapDone: ;65
       lda    $FFFB               ;4 69 Select last bank
       jmp    MapKernel           ;3
      ENDIF
KernelDone: ;55
       lda    $FFFB               ;4 59 Select last bank
    ELSE
       lda    $FFF9               ;4
       jmp    StartGame           ;3 Go to cold start routine in last bank
      IF USE_TITLE_DISPLAY
TitleDone: ;65
       lda    $FFF9               ;4 69 Select last bank
       jmp    TitleKernel         ;3
MapDone: ;65
       lda    $FFF9               ;4 69 Select last bank
       jmp    MapKernel           ;3
      ENDIF
KernelDone: ;55
       lda    $FFF9               ;4 59 Select last bank
    ENDIF
 
;47 from other bank...
       ldy    #$00                ;2 48 Set initial room definition index
       lda    (RoomLo),y          ;5 53 Get PF0 and control bits for this row
       sta    ENAM0               ;3 56 Enable left hand wall(if wanted-missle00)
       iny                        ;2 58
       sta    PF0                 ;3 61 ...And display PF0
       and    #$0D                ;2 63 Keep only low nybble of PF0
       ora    #$20                ;2 65 Merge in the ball size
       sta    CTRLPF              ;3 68 Store to playfield control
       lsr                        ;2 70 Roll right panel enable
       lsr                        ;2 72 Roll right panel enable
       sta    ENAM1               ;3 76 Carry clear-Enable right hand wall(if wanted-missle01)
;-----------------------------------
       sty    VBLANK              ;3 03 Clear any Vertical Blank
       lda    (RoomLo),y          ;5 08 Get PF1 definition byte
       sta    PF1                 ;3 11 ...And display
       iny                        ;2 13 Bump index
       lda    (RoomLo),y          ;5 18 Get PF2 definition byte
       sta    PF2                 ;3 21 ...And display
       iny                        ;2 23 Bump index
       lda    (RoomLo),y          ;5 28 Get # of scanlines for this band
       sta.w  PixelCount          ;4 32 Store to line counter
       lda    #$04                ;2 34
       bne    Print_Top_Line      ;3 37 Always branch
 
DrawNextPlayfield: ;67
       ldy    NextPF1             ;3 70 Grab new band data from cache
       lda    NextPF0             ;3 73 .
       sta    ENAM0               ;3 76 Enable left hand wall(if wanted)
;-----------------------------------
       sta    PF0                 ;3 03 Transfer cache to playfield registers
       sty    PF1                 ;3 06 .
       and    #$0D                ;2 08 .
       ora    #$20                ;2 10 .
       sta    CTRLPF              ;3 13 .
       ldy    NextPF2             ;3 16 .
       sty    PF2                 ;3 19 .
       lsr                        ;2 21 .
       lsr                        ;2 23 .
       sta    ENAM1               ;3 26 Enable right hand wall(if wanted)...carry is clear now
       lda    NextCount           ;3 29 .
       sta    PixelCount          ;3 32 Store to line counter
       lda    RoomDefIndex        ;3 35 Load room gfx pointer
       adc    #$04                ;2 37 Bump the LSB by 4 bytes
Print_Top_Line: ;37 - Carry clear
       sta    RoomDefIndex        ;3 40 Update
       .byte $2C                  ;4 44 Skip next 2 bytes (BIT.w)
SkipPlayfieldUpdate: ;41 - Carry clear
       sta    NextCount           ;3 41 Update cache
SkipPlayfieldUpdate2: ;44 - Carry clear
       dex                        ;2 46 Decrease double-scanline counter
       txs                        ;2 48 Save the current scanline counter temporarily
       txa                        ;2 50 Flip to A as well to check the ball
       tay                        ;2 52
       beq    KernelDone          ;2 54 Branch if display finished
       lda    (Ball),y            ;5 59
       ldy    #$00                ;2 61
       sta    ENABL               ;3 64 Display Ball (If Wanted)
       lax    (Obj1Lo),y          ;5 69 Get the next Object1 bitmap value (pass to X)
       lda    (Obj2Lo),y          ;5 74 Get the next Object2 bitmap value
       iny                        ;2 76 Bump index to load color data
;-----------------------------------
       stx    GRP0                ;3 03 Display both sprite bitmaps
       sta    GRP1                ;3 06 .
       lda    (Obj2Lo),y          ;5 11 Get the color info for Object2
       sta    COLUP1              ;3 14 Recolor Object2
       lda    (Obj1Lo),y          ;5 19 Get the color info for Object1
       sta    COLUP0              ;3 22 Recolor Object1
       beq    Waste11             ;2 24 Branch if color = 0 (delimiter)
       tsx                        ;2 26 Restore saved scanline counter
       cpx    Obj1Y               ;3 29 Have we reached Object1's Y Co-ordinate?
       bpl    Waste4              ;2 31 If not, continue to use first bitmap value (0)
       lda    Obj1Lo              ;3 34 (Carry clear) Otherwise, load the LSB
       adc    #$02                ;2 36 ...And bump by 2 for next time
       sta    Obj1Lo              ;3 39 Update
Object1skipped: ;39
       lda    (Obj2Lo),y          ;5 44 Get the Next Player00 definition byte (give to X)
       beq    Waste11_2           ;2 46 Branch if color = 0 (delimiter)
       cpx    Obj2Y               ;3 49 Have we reached Object2's Y Co-ordinate?
       bpl    Waste4_2            ;2 51 If not, continue to use first bitmap value (0)
       lda    Obj2Lo              ;3 54 (Carry clear) Otherwise, load the LSB
       adc    #$02                ;2 56 ...And bump by 2 for next time
       sta    Obj2Lo              ;3 59 Update
Object2skipped: ;59
       dec    PixelCount          ;5 64 Decrement the line counter
       beq    DrawNextPlayfield   ;2 66 If more lines remain, branch
       ldy.w  RoomDefIndex        ;4 70 Update cache...load current index
       tya                        ;2 72 Flip current index to A
       adc    RoomLo              ;3 75 ...And add the LSB
;-----------------------------------
       cmp    #$FD                ;2 01 Check if less than 4 bytes remain in current page
       bcs    PageUpdate          ;2 03 Branch if so (and adjust pointers to next page)
       lda    (RoomLo),y          ;5 08 Get PF0 value for next band (if any)
       sta    NextPF0             ;3 11 Update cache
       iny                        ;2 13 Bump index
       lda    (RoomLo),y          ;5 18 Get PF1 value for next band (if any)
       sta    NextPF1             ;3 21 Update cache
       iny                        ;2 23 Bump index
       lda    (RoomLo),y          ;5 28 Get PF2 value for next band (if any)
       sta    NextPF2             ;3 31 Update cache
       iny                        ;2 33 Bump index
       lda    (RoomLo),y          ;5 38 Get # of scanlines for next band (if any)
       jmp    SkipPlayfieldUpdate ;3 41 ...And jump back into the kernel
 
PageUpdate: ;04
       ldy    #$05                ;2 06 Set to waste 24 cycles
       inc    RoomHi              ;5 11 Move pointer to next page
WasteLoop:
       dey                        ;2 13/18/23/28/33
       bne    WasteLoop           ;2 16/21/27/31/35
       sty    RoomDefIndex        ;3 38 Set both pointers to zero
       sty    RoomLo              ;3 41 .
       beq    SkipPlayfieldUpdate2;3 44 Always branch
 
Waste11: ;25
       tsx                        ;2 27 Restore saved scanline counter
       dec    Waste2              ;5 32 Object1 not reached yet...kill time
Waste4: ;32
       clc                        ;2 34 Object1 done...kill time
       clc                        ;2 36
       bcc    Object1skipped      ;3 39 Always branch
 
Waste11_2: ;47
       dec    Waste2              ;5 52 Object2 not reached yet...kill time
Waste4_2: ;52
       clc                        ;2 54 Object2 done...kill time
       clc                        ;2 56
       bcc    Object2skipped      ;3 59 Always branch
 
    IF MULTICOLOR
;21-byte difference needed to align following data should both kernels be used
       .byte "Nukey Shay-03/09/2011"
    ENDIF
  ENDM
 
 
 
  MAC Multicolor_Display_Kernel2
    IF BANKS = 2
       lda    $FFFB               ;4
       jmp    StartGame           ;3 Go to cold start routine in last bank
      IF USE_TITLE_DISPLAY
TitleDone: ;65
       lda    $FFFB               ;4 69 Select last bank
       jmp    TitleKernel         ;3
MapDone: ;65
       lda    $FFFB               ;4 69 Select last bank
       jmp    MapKernel           ;3
      ENDIF
MKernelDone: ;55
       lda    $FFFB               ;4 59 Select last bank
    ELSE
       lda    $FFF9               ;4
       jmp    StartGame           ;3 Go to cold start routine in last bank
      IF USE_TITLE_DISPLAY
TitleDone: ;65
       lda    $FFF9               ;4 69 Select last bank
       jmp    TitleKernel         ;3
MapDone: ;65
       lda    $FFF9               ;4 69 Select last bank
       jmp    MapKernel           ;3
      ENDIF
MKernelDone: ;55
       lda    $FFF9               ;4 59 Select last bank
    ENDIF
 
;47 from other bank...
 
       ldy    #$05                ;2 50 Set room gfx pointer to 5 bytes in
       sty    RoomDefIndex        ;3 53 ...And save for next time
       ldy    #$00                ;2 55 Set initial room definition index
       lda    (RoomLo),y          ;5 60 Get color for top band
       sta    COLUPF              ;3 63 Display
       iny                        ;2 65 Bump index
       lda    (RoomLo),y          ;5 70 Get PF0 and control bits for top row
       sta    ENAM0               ;3 73 Enable left hand wall(if wanted-missle00)
       sta.w  PF0                 ;4 76 ...And display PF0
;-----------------------------------
       sty    VBLANK              ;3 03 Clear any Vertical Blank
       iny                        ;2 05 Bump index
       and    #$0D                ;2 07 Keep only low nybble of PF0
       ora    #$20                ;2 09 Merge in the ball size
       sta    CTRLPF              ;3 12 Store to playfield control
       lsr                        ;2 14 Roll right panel enable
       lsr                        ;2 16 Roll right panel enable
       sta    ENAM1               ;3 19 Enable right hand wall(if wanted-missle01)
       lda    (RoomLo),y          ;5 24 Get PF1 of top row
       sta    PF1                 ;3 27 ...And display
       iny                        ;2 29 Bump index
       lda    (RoomLo),y          ;5 34 Get PF2 of top row
       sta    PF2                 ;3 37 ...And display
       iny                        ;2 39 Bump index
       lda    (RoomLo),y          ;5 44 Get # of scanlines for top row
       jmp    MPrint_Top_Line     ;3 47 Jump mid-kernel to store
 
 
MDrawNextPlayfield: ;69
       ldy    NextPF1             ;3 72 Otherwise, update playfield using cached values
       lda    NextCOLUPF          ;3 75
;-----------------------------------
       asl                        ;2 01 . (value was LSR'ed to check for color change)
       sty    PF1                 ;3 04 . (carry clear from above)
       sta    COLUPF              ;3 07 .
       lda    NextPF0             ;3 10 .
       sta    ENAM0               ;3 13 . Enable left hand wall(if wanted)
       sta    PF0                 ;3 16 .
       and    #$0D                ;2 18 .
       ora    #$20                ;2 20 .
       sta    CTRLPF              ;3 23 .
       ldy    NextPF2             ;3 26 .
       sty    PF2                 ;3 29 .
       lsr                        ;2 31 .
       lsr                        ;2 33 .
       sta    ENAM1               ;3 36 . Enable right hand wall(if wanted)...carry clear now
       lda    RoomDefIndex        ;3 39 Get current pointer to room graphics
       adc    #$05                ;2 41 Bump index by 5 bytes for next time
       sta    RoomDefIndex        ;3 44 Update
       lda    NextCount           ;3 47 Load new line counter from cache
MPrint_Top_Line: ;47
       sta    PixelCount          ;3 50 Update line counter
MSkipPlayfieldUpdate: ;50
       dex                        ;2 52 Decrease double-scanline counter
       beq    MKernelDone         ;2 54 Branch if display finished
       txa                        ;2 56 Flip to A as well to set ball display
       tay                        ;2 58
       lda    (Ball),y            ;5 63
       sta    ENABL               ;3 66 Display Ball (If Wanted)
       ldy    #$00                ;2 68 Clear Y index
       lda    (Obj1Lo),y          ;5 73 Get the next Object1 bitmap value
       sta    GRP0                ;3 76 ...And display
;-----------------------------------
       lda    (Obj2Lo),y          ;5 05 Get the next Object2 bitmap value
       sta    GRP1                ;3 08 ...And display
       iny                        ;2 10 Bump index
       lda    (Obj2Lo),y          ;5 15 Get the color value for Object2
       sta    COLUP1              ;3 18 Update
       lda    (Obj1Lo),y          ;5 23 Get the color value for Object1
       sta    COLUP0              ;3 26 Update
       beq    MWaste11            ;2 28 Branch if color = 0 (delimiter)
       cpx    Obj1Y               ;3 31 Have we reached Object1's Y Co-ordinate?
       bpl    MWaste4             ;2 33 If not, continue to use first bitmap value (0)
       lda    Obj1Lo              ;3 36 (Carry clear) Otherwise, load the LSB
       adc    #$02                ;2 38 ...And bump by 2 for next time
       sta    Obj1Lo              ;3 41
MObject1skipped: ;41
       lda    (Obj2Lo),y          ;5 46 Get the Next Player00 definition byte (give to X)
       beq    MWaste11_2          ;2 48 Branch if color = 0 (delimiter)
       cpx    Obj2Y               ;3 51 Have we reached Object2's Y co-ordinate?
       bpl    MWaste4_2           ;2 53 If not, continue to use first bitmap value (0)
       lda    Obj2Lo              ;3 56 (Carry clear) Otherwise, load the LSB
       adc    #$02                ;2 58 ...And bump by 2 for next time
       sta    Obj2Lo              ;3 61
MObject2skipped: ;61
       dec    PixelCount          ;5 66 Decrement the line counter
       beq    MDrawNextPlayfield  ;2 68 If more lines remain, branch and cache next line
       ldy    RoomDefIndex        ;3 71 Get current room definition index
       lda    (RoomLo),y          ;5 76 Get color data for next band (if any)
;-----------------------------------
       iny                        ;2 02 Bump index
       lsr                        ;2 04 Move bit0 to carry to check for a color change
       bcs    MUpdateColorOnly    ;2 06 Branch if set (and load next color only)
       sta    NextCOLUPF          ;3 09 Otherwise, store (value will be ASL'ed later)
       lda    (RoomLo),y          ;5 14 Get PF0 data for next band (if any)
       sta    NextPF0             ;3 17
       iny                        ;2 19 Bump index
       lda    (RoomLo),y          ;5 24 Get PF1 data for next band (if any)
       sta    NextPF1             ;3 27
       iny                        ;2 29 Bump index
       lda    (RoomLo),y          ;5 34 Get PF2 data for next band (if any)
       sta    NextPF2             ;3 37
       iny                        ;2 39 Bump index
       lda    (RoomLo),y          ;5 44 Get # of scanlines for next band (if any)
       sta    NextCount           ;3 47
MSkipJmp:
       jmp    MSkipPlayfieldUpdate;3 50 Jump back into the kernel
 
 
MWaste11: ;29
       dec    Waste2              ;5 34 Object1 not reached yet...kill time
MWaste4: ;34
       clc                        ;2 36 Object1 done...kill time
       clc                        ;2 38
       bcc    MObject1skipped     ;3 41 Always branch
 
 
MWaste11_2: ;49
       dec    Waste2              ;5 54 Object2 not reached yet...kill time
MWaste4_2: ;54
       clc                        ;2 56 Object2 done...kill time
       clc                        ;2 58
       bcc    MObject2skipped     ;3 61 Always branch
 
 
MUpdateColorOnly: ;07
       rol                        ;2 09
       sta    COLUPF              ;3 12 Carry clear, update displayed color
       tya                        ;2 14 Check for page break by moving index to A
       adc    RoomLo              ;3 17 ...And adding LSB of room pointer
       bcc    MSkipPageUpdate     ;2 19 Branch if page not crossed
       sta    RoomDefIndex        ;3 22 Otherwise, update the pointers
       sta    RoomLo              ;3 25
       inc    RoomHi              ;5 30 ...And bump to next page
       ldy    #$02                ;2 32 Set to waste 9 additional cycles
       bne    MWasteLoop          ;3 35 Always branch
MSkipPageUpdate: ;20
       sty    RoomDefIndex        ;3 23 If page wasn't crossed, adjust current pointer +1 byte
       ldy    #$04                ;2 25 Set to waste 19 additional cycles
MWasteLoop: ;35
       dey                        ;2 27/32/37/42 Kill off remaining cycles
       bne    MWasteLoop          ;2 30/35/40/44
       beq    MSkipJmp            ;3 47 Always branch
  ENDM
 
 
 
 
 
;basic level-select screen...
  MAC Titlescreen
;       ALIGN 256,0
TitleKernel:
       inc    LoCnt               ;5 Bump low counter to help with random selection later
       lda    Level               ;3 Get current level
       and    #$0E                ;2 Trim off sound effect and console type bits
       tay                        ;2 Pass to Y
       lda    GameNumGFX,y        ;4 Get address LSB of GFX to use for this level
       sta    Ball                ;3 Pass to ram for later (indirect),y access
       lda    GameNumGFX+1,y      ;4 Do the same for it's MSB
       sta    Ball+1              ;3 .
;NOTE: a LOT of time exists before this loop...so you can design any title you want!
;      I just used a very basic kernel by setting an indirect address above for the
;      level number, and drew block letters using standard PF tables ahead.
Title_Wait:
       ldx    INTIM               ;4 Wait for end of the current frame
       bne    Title_Wait          ;2 .
       sta    WSYNC               ;3 Wait for horizontal Blank
       sta    WSYNC               ;3 Wait for horizontal Blank
;-----------------------------------
       stx    VBLANK              ;3 Clear any Vertical Blank
       stx    COLUBK              ;3 Clear background color
       stx    CTRLPF              ;3 Set display mode to Mirrored (PF0 PF1 PF2 PF0 PF1 PF2)
  IF PAL
       lda    #$2A                ;2 Gold
  ELSE
       lda    #$1A                ;2 Yellow
  ENDIF
       sta    COLUPF              ;3 Set color of upper text
       ldy    #$04                ;2 Set number of pixels (data bytes) for this block of text
DrawTopInit: ;57
       ldx    #$0F                ;2 Set number of scanlines to use for each data line
DrawTopLoop: ;53
       sta    WSYNC               ;3 Wait for horizontal Blank
       lda    Top_PF1,y           ;4 04 Update PF registers for left half
       sta    PF1                 ;3 07 .
       lda    Top_PF2,y           ;4 11 .
       sta    PF2                 ;3 14 .
       lda    Top_PF0,y           ;4 18 .
       sta    PF0                 ;3 21 .
       asl                        ;2 23 Lower nybble of data contains right side
       asl                        ;2 25 .
       asl                        ;2 27 .
       asl                        ;2 29 .
       nop                        ;2 31 Waste 2 more cycles between halves
       sta    PF0                 ;3 34 Update PF registers for right half
       lda    Top_PF4,y           ;4 38 .
       sta    PF1                 ;3 41 .
       lda    Top_PF5,y           ;4 45 .
       sta    PF2                 ;3 48 .
       dex                        ;2 50 Reduce scanline counter
       bne    DrawTopLoop         ;2 52 Loop to continue current data if non-zero
       dey                        ;2 54 Reduce pixel counter
       bpl    DrawTopInit         ;2 56 Loop to read next data if no rollover
       sta    WSYNC               ;3 Wait for horizontal Blank
  IF PAL
       lda    #$4A                ;2 Light orange
  ELSE
       lda    #$3A                ;2 Light orange
  ENDIF
       sta    COLUPF              ;3 Set color of lower text
       stx    PF0                 ;3 Clear pixel data between text lines
       stx    PF1                 ;3 .
       stx    PF2                 ;3 .
       ldx    #$07                ;2 Set number of additional scanlines to waste between text
DrawGapLoop:
       sta    WSYNC               ;3 Wait for horizontal Blank
       dex                        ;2 Bump scanline counter
       bne    DrawGapLoop         ;2 Loop to waste scanlines
       ldy    #$04                ;2 Set number of pixels (data bytes) for this block of text
DrawBottomInit: ;58
       ldx    #$0F                ;2 Set number of scanlines to use for each data line
DrawBottomLoop: ;54
       sta    WSYNC               ;3 Wait for horizontal Blank
       lda    Bottom_PF1,y        ;4 04 Update PF registers for left half
       sta    PF1                 ;3 07 .
       lda    Bottom_PF2,y        ;4 11 .
       sta    PF2                 ;3 14 .
       lda    Bottom_PF0,y        ;4 18 .
       sta    PF0                 ;3 21 .
       asl                        ;2 23 Lower nybble of data contains right side
       asl                        ;2 25 .
       asl                        ;2 27 .
       asl                        ;2 29 .
       dex                        ;2 31 Reduce scanline counter
       sta    PF0                 ;3 34 Update PF registers for right half
       lda    Bottom_PF4,y        ;4 38 .
       sta    PF1                 ;3 41 .
       lda    (Ball),y            ;5 46 .
       sta    PF2                 ;3 49 .
       txa                        ;2 51 Check scanline counter
       bne    DrawBottomLoop      ;2 53 Loop to continue current data if non-zero
       dey                        ;2 55 Reduce pixel counter
       bpl    DrawBottomInit      ;2 57 Loop to read next data if no rollover
       ldx    #$0B                ;2 59 Waste 54 add'l cycles before returning to last bank
       ldy    #$20                ;2 61 Set number of scanlines to waste at the bottom
WasteLines:
       sta    PF0                 ;3 64 Clear PF registers
       sta    PF1                 ;3 67 .
       sta    WSYNC               ;3 Wait for horizontal Blank
       sta.w  PF2                 ;4 04 .
       dey                        ;2 06 Bump scanline counter
       bne    WasteLines          ;2 08 Loop to waste lines
Kill54cycles:
       dex                        ;2 10/15/20/25/30/35/40/45/50/55/60
       bne    Kill54cycles        ;2 13/18/23/28/33/38/43/48/53/58/62
       jmp    TitleDone           ;3 Needs to hit @ cycle 65 with X = 0 (the only requirements)
;"ADVENTURE" text
Top_PF0:
       .byte #%10000010       ; Block pixels 5
       .byte #%10000010       ; Block pixels 4
       .byte #%10000010       ; Block pixels 3
       .byte #%10000010       ; Block pixels 2
       .byte #%00001001       ; Block pixels 1
Top_PF1:
       .byte #%01011001       ; Block pixels 5
       .byte #%11010101       ; Block pixels 4
       .byte #%01010101       ; Block pixels 3
       .byte #%01010101       ; Block pixels 2
       .byte #%10011001       ; Block pixels 1
Top_PF2:
       .byte #%10111000       ; Block pixels 5
       .byte #%10001001       ; Block pixels 4
       .byte #%10011010       ; Block pixels 3
       .byte #%10001010       ; Block pixels 2
       .byte #%10111010       ; Block pixels 1
Top_PF4:
       .byte #%10001101       ; Block pixels 5
       .byte #%10010101       ; Block pixels 4
       .byte #%10010101       ; Block pixels 3
       .byte #%10010101       ; Block pixels 2
       .byte #%11010101       ; Block pixels 1
Top_PF5:
       .byte #%00111010       ; Block pixels 5
       .byte #%00001001       ; Block pixels 4
       .byte #%00011010       ; Block pixels 3
       .byte #%00001010       ; Block pixels 2
       .byte #%00111001       ; Block pixels 1
;"GAME#" text
Bottom_PF0:
       .byte #%00001110       ; Block pixels 10
       .byte #%10000010       ; Block pixels 9
       .byte #%10001110       ; Block pixels 8
       .byte #%10000010       ; Block pixels 7
       .byte #%00001110       ; Block pixels 6
Bottom_PF1:
       .byte #%11110100       ; Block pixels 10
       .byte #%00010111       ; Block pixels 9
       .byte #%01110100       ; Block pixels 8
       .byte #%00000010       ; Block pixels 7
       .byte #%11110001       ; Block pixels 6
Bottom_PF2:
       .byte #%10001010       ; Block pixels 10
       .byte #%10001011       ; Block pixels 9
       .byte #%10101010       ; Block pixels 8
       .byte #%11011001       ; Block pixels 7
       .byte #%10001000       ; Block pixels 6
Bottom_PF4:
       .byte #%11001010       ; Block pixels 10
       .byte #%00011111       ; Block pixels 9
       .byte #%00001010       ; Block pixels 8
       .byte #%00011111       ; Block pixels 7
       .byte #%11001010       ; Block pixels 6
Bottom_PF5_1: ;"1" text
       .byte #%00011100       ; Block pixels 10
       .byte #%00001000       ; Block pixels 9
       .byte #%00001000       ; Block pixels 8
       .byte #%00001100       ; Block pixels 7
       .byte #%00001000       ; Block pixels 6
Bottom_PF5_2: ;"2" text
       .byte #%00111110       ; Block pixels 10
       .byte #%00000010       ; Block pixels 9
       .byte #%00011100       ; Block pixels 8
       .byte #%00100000       ; Block pixels 7
       .byte #%00011100       ; Block pixels 6
Bottom_PF5_3: ;"3" text
       .byte #%00011100       ; Block pixels 10
       .byte #%00100010       ; Block pixels 9
       .byte #%00011000       ; Block pixels 8
       .byte #%00100000       ; Block pixels 7
       .byte #%00011100       ; Block pixels 6
 
GameNumGFX: ;add more bitmaps if you increase the number of game variations
       .word Bottom_PF5_1 ;GFX for level 1
       .word Bottom_PF5_2 ; "" level 2
       .word Bottom_PF5_3 ; "" level 3
  ENDM
 
 
  MAC MapScreen
;NOTE: a LOT of time exists before the INTIM loop...so you can design any map you want!
MapKernel:
       sta    WSYNC               ;3 Wait for horizontal Blank
       sta    HMOVE               ;3 Update dot's position
       lda    #$00                ;2
       sta    VDELBL              ;3 Disable ball delay
       ldx    PlayerX             ;3 Deal with moving the small pixel...load current X
       ldy    PlayerY             ;3 ...And Y
       lda    SWCHA               ;4 Then grab the stick's direction
  IF MERGE_STICKS
       asl                        ;2 Push the right stick high...
       asl                        ;2 .
       asl                        ;2 .
       asl                        ;2 .
       and    SWCHA               ;4 ...And mix with the left stick
  ENDIF
       asl                        ;2 Push "right" into carry
       bcs    Not_Mapping_Right   ;2 Branch if not moving that direction
       inx                        ;2 Otherwise, bump X co-ordinate up by 1 pixel
Not_Mapping_Right:
       asl                        ;2 Push "left" into carry
       bcs    Not_Mapping_Left    ;2 Branch if not moving that direction
       dex                        ;2 Otherwise, bump X co-ordinate down by 1 pixel
Not_Mapping_Left:
       asl                        ;2 Push "down" into carry
       bcs    Not_Mapping_Down    ;2 Branch if not moving that direction
       dey                        ;2 Otherwise, bump Y co-ordinate down by 1 pixel
       bne    Not_Mapping_Down    ;2 Branch if no wraparound
       ldy    #$BD                ;2 Or reset Y co-ordinate to top border
Not_Mapping_Down:
       asl                        ;2 Push "up" into carry
       bcs    Not_Mapping_Up      ;2 Branch if not moving that direction
       iny                        ;2 Otherwise, bump Y co-ordinate up by 1 pixel
       cpy    #$BE                ;2 Check for wraparound
       bcc    Not_Mapping_Up      ;2 Branch if none
       ldy    #$01                ;2 Or reset Y co-ordinate to bottom border
Not_Mapping_Up:
       txa                        ;2 Move horizontal to A
       and    #$7F                ;2 Trim upper bit (if present) to handle wraparound
Map_Wait:
       ldx    INTIM               ;4 Wait for end of the current frame
       bne    Map_Wait            ;2 .
       sta    WSYNC               ;3 Wait for horizontal Blank
;-----------------------------------
       stx    VBLANK              ;3 Clear any Vertical Blank
       sta    PlayerX             ;3 Update dot's co-ordinates
       sty    PlayerY             ;3 .
       stx    PF0                 ;3 Clear any PF graphics
       stx    PF1                 ;3 .
       stx    PF2                 ;3 .
       stx    COLUBK              ;3 Black background
       stx    REFP0               ;3 Clear any sprite reflect
       stx    REFP1               ;3 .
       stx    CTRLPF              ;3 Set ball = small
       stx    Temp                ;3 Set temporary collisions to none ($00)
       dex                        ;2
       stx    COLUPF              ;3 Give a color to the ball
       lda    #$04                ;2 Set sprite positions to 2 wide copies
       sta    NUSIZ0              ;3 Update sprite control
       sta    NUSIZ1              ;3 .
       sta    CXCLR               ;3 Clear previous collisions
       sta    HMCLR               ;3 ...And horizontal motion
       sta    HMP0                ;3 Update new positions for the icons
       lda    #$10                ;2 .
       sta    HMP1                ;3 .
       sta    RESP0               ;3 Update sprite horizontal locations
       sta    RESP1               ;3 .
       ldx    #$BD                ;2 Set total number of scanlines to draw
Above_Map_Screen:
       sta    WSYNC               ;3 Wait for horizontal Blank
;-----------------------------------
       sta    HMOVE               ;3 03 Move icons to their proper spots
       cpx    PlayerY             ;3 06 Check player's vertical location
       php                        ;3 09 .
       pla                        ;4 13 .
       sta    ENABL               ;3 16 ...By using carry status
       dex                        ;2 18 Bump scanline count
       dec    Waste2              ;5 23 (Waste a little time for upcoming HMCLR)
       cpx    #$A0                ;2 25 Is the upper blank area finished?
       sta    HMCLR               ;3 28
       bcs    Above_Map_Screen    ;2 30 Branch if not
       ldy    #$0F                ;2 32 Set the top area icon height
Map_Screen_Top: ;58
       cpx    PlayerY             ;3 61 Check player's vertical location
       php                        ;3 64 .
       pla                        ;4 68 .
       sta    WSYNC               ;3 Wait for horizontal Blank
;-----------------------------------
       sta    ENABL               ;3 03 ...By using carry status
       lda    AreaT1gfx,y         ;4 07 Update the gfx for the left icon
       sta    GRP0                ;3 10 .
       lda    AreaT2gfx,y         ;4 14 .
       sta    GRP1                ;3 17 .
       lda    AreaT1color,y       ;4 21 .
       sta    COLUP0              ;3 24 .
       sta    COLUP1              ;3 27 .
       dex                        ;2 29 Bump scanline count
       lda    AreaT3gfx,y         ;4 33 Then update the gfx for the right icon
       sta    GRP0                ;3 36 .
       lda    AreaT4gfx,y         ;4 40 .
       sta    GRP1                ;3 43 .
       lda    AreaT2color,y       ;4 47 .
       sta    COLUP0              ;3 50 .
       sta    COLUP1              ;3 53 .
       dey                        ;2 55 Finished drawing upper icons?
       bpl    Map_Screen_Top      ;2 57 Branch if not
       ldy    #$30                ;2 59 Gap between top and middle areas
Map_Screen_Top_Gap:
       sta    WSYNC               ;3 Wait for horizontal Blank
;-----------------------------------
       cpx    PlayerY             ;3 03 Check player's vertical location
       php                        ;3 06 .
       pla                        ;4 10 .
       sta    ENABL               ;3 13 ...By using carry status
       lda    #$00                ;2 15 Clear top icon gfx
       sta    GRP0                ;3 18 .
       sta    GRP1                ;3 21 .
       dex                        ;2 23 Bump scanline count
       dey                        ;2 25 Done drawing this gap?
       bpl    Map_Screen_Top_Gap  ;2 27 Branch if not
       ldy    #$02                ;2 29 Pointer for top area
       lda    CXP0FB              ;3 32 Mix both collision registers
       ora    CXP1FB              ;3 35 .
       and    #$40                ;2 37 Check for ball collisions
       beq    Top_Not_Hit         ;2 39 Branch if none in this section
       sty    Temp                ;3 42 Save top area collisions
Top_Not_Hit: ;40
       sta    CXCLR               ;3 45 Clear collisions for next area
       ldy    #$0F                ;2 47 Middle area icon height
Map_Screen_Middle: ;58
       cpx    PlayerY             ;3 61 Check player's vertical location
       php                        ;3 64 .
       pla                        ;4 68 .
       sta    WSYNC               ;3 Wait for horizontal Blank
;-----------------------------------
       sta    ENABL               ;3 03 ...By using carry status
       lda    AreaM1gfx,y         ;4 07 Update the gfx for the left icon
       sta    GRP0                ;3 10 .
       lda    AreaM2gfx,y         ;4 14 .
       sta    GRP1                ;3 17 .
       lda    AreaM1color,y       ;4 21 .
       sta    COLUP0              ;3 24 .
       sta    COLUP1              ;3 27 .
       dex                        ;2 29 Bump scanline count
       lda    AreaM3gfx,y         ;4 33 Then update the gfx for the right icon
       sta    GRP0                ;3 36 .
       lda    AreaM4gfx,y         ;4 40 .
       sta    GRP1                ;3 43 .
       lda    AreaM2color,y       ;4 47 .
       sta    COLUP0              ;3 50 .
       sta    COLUP1              ;3 53 .
       dey                        ;2 55 Finished drawing middle icons?
       bpl    Map_Screen_Middle   ;2 57 Branch if not
       ldy    #$30                ;2 59 Gap between middle and bottom areas
Map_Screen_Mid_Gap:
       sta    WSYNC               ;3 Wait for horizontal Blank
;-----------------------------------
       cpx    PlayerY             ;3 03 Check player's vertical location
       php                        ;3 06 .
       pla                        ;4 10 .
       sta    ENABL               ;3 13 ...By using carry status
       lda    #$00                ;2 15 Clear middle icon gfx
       sta    GRP0                ;3 18 .
       sta    GRP1                ;3 21 .
       dex                        ;2 23 Bump scanline count
       dey                        ;2 25 Done drawing this gap?
       bpl    Map_Screen_Mid_Gap  ;2 27 Branch if not
       ldy    #$08                ;2 29 Pointer for middle area
       lda    CXP0FB              ;3 32 Mix both collision registers
       ora    CXP1FB              ;3 35 .
       and    #$40                ;2 37 Check for ball collisions
       beq    Middle_Not_Hit      ;2 39 Branch if none in this section
       sty    Temp                ;3 42 Save middle area collisions
Middle_Not_Hit: ;40
       sta    CXCLR               ;3 45 Clear collisions for next area
       ldy    #$0F                ;2 47 Bottom area icon height
Map_Screen_Bottom: ;58
       cpx    PlayerY             ;3 61 Check player's vertical location
       php                        ;3 64 .
       pla                        ;4 68 .
       sta    WSYNC               ;3 Wait for horizontal Blank
;-----------------------------------
       sta    ENABL               ;3 03 ...By using carry status
       lda    AreaB1gfx,y         ;4 07 Update the gfx for the left icon
       sta    GRP0                ;3 10 .
       lda    AreaB2gfx,y         ;4 14 .
       sta    GRP1                ;3 17 .
       lda    AreaB1color,y       ;4 21 .
       sta    COLUP0              ;3 24 .
       sta    COLUP1              ;3 27 .
       dex                        ;2 29 Bump scanline count
       lda    AreaB3gfx,y         ;4 33 Then update the gfx for the right icon
       sta    GRP0                ;3 36 .
       lda    AreaB4gfx,y         ;4 40 .
       sta    GRP1                ;3 43 .
       lda    AreaB2color,y       ;4 47 .
       sta    COLUP0              ;3 50 .
       sta    COLUP1              ;3 53 .
       dey                        ;2 55 Finished drawing bottom icons?
       bpl    Map_Screen_Bottom   ;2 57 Branch if not
Map_Screen_Bot_Gap: ;23
       cpx    PlayerY             ;3 60 Check player's vertical location
       sta    WSYNC               ;3 Wait for horizontal Blank
;-----------------------------------
       php                        ;3 03 .
       pla                        ;4 07 .
       sta    ENABL               ;3 10 ...By using carry status
       lda    #$00                ;2 12 Clear bottom icon gfx
       sta    GRP0                ;3 15 .
       sta    GRP1                ;3 18 .
       dex                        ;2 20 Bump scanline count
       bpl    Map_Screen_Bot_Gap  ;2 22 Branch if any still remain
       ldy    #$0E                ;2 24 Pointer for bottom area
       lda    CXP0FB              ;3 27 Mix both collision registers
       ora    CXP1FB              ;3 30 .
       and    #$40                ;2 32 Check for ball collisions
       beq    Bottom_Not_Hit      ;2 34 Branch if none in this section
       .byte $2C                  ;4 38 Skip next 2 bytes
Bottom_Not_Hit: ;35
       ldy    Temp                ;3 38 Load previous collisions
       tya                        ;2 40 Flip to A instead of using CPY (saves a byte)
       beq    No_Icons_Hit        ;2 42 Branch if no icons collided with
       bit.w  PlayerX             ;4 46 Check horizontal position
       bvc    Left_Side           ;2 48 Branch if on the left
       iny                        ;2 50 Otherwise, increase pointer by 3
       iny                        ;2 52 .
       iny                        ;2 54 .
Left_Side2: ;54
       sty    Temp                ;3 57 Save pointer for later
       sta    CXCLR               ;3 60 Clear collisions
       lda    HiCnt               ;3 63
       and    #$FD                ;2 65 Remove "map display" bit
       sta    HiCnt               ;3 68
       ldx    #$03                ;2 70 Set to transfer 3 bytes to player
Entry_Transfer_Loop:
       lda    New_Room_Entered,y  ;4 74/21/44 Get first room # for this area
       sta    PlayerRoom-1,x      ;4 02/25/48 Update player info
       sta    PrevRoom-1,x        ;4 06/29/52 ...And previous info
       sta    MapPortR-1,x        ;4 10/33/56 ...And new portal location
       dey                        ;2 12/35/58
       dex                        ;2 14/37/60
       bne    Entry_Transfer_Loop ;2 17/40/62
       jmp    MapDone             ;3 Needs to hit @ cycle 65 with X = 0 (the only requirements)
 
No_Icons_Hit: ;43
       ldx    #$0C                ;2 Waste 59 add'l cycles before returning to last bank
       sta    WSYNC               ;3 Wait for horizontal Blank
;-----------------------------------
       sta    CXCLR               ;3 03
Kill59cycles:
       dex                        ;2 05/10/15/20/25/30/35/40/45/50/55/60
       bne    Kill59cycles        ;2 08/13/18/23/28/33/38/43/48/53/58/62
       jmp    MapDone             ;3 Needs to hit @ cycle 65 with X = 0 (the only requirements)
 
Left_Side: ;49
       clc                        ;2 51
       bcc    Left_Side2          ;3 54 Always branch
 
New_Room_Entered: ;This table must not cross a page break...it's very time-critical!
       .byte <(Rm12-Rm00),$4D,$30 ;Entry point for first icon (inside the yellow castle!)
       .byte <(Rm02-Rm00),$4D,$30 ;...Second (below yellow castle)
       .byte <(Rm1D-Rm00),$4D,$30 ;...Third (lower dungeon room)
       .byte <(Rm06-Rm00),$4D,$30 ;...Fourth (large open area in the hedge maze)
       .byte <(Rm1C-Rm00),$4D,$30 ;...Fifth (upper dungeon room - in black castle for game 1)
       .byte <(Rm0E-Rm00),$4D,$30 ;...Sixth (dungeon below white castle - try it in game 1!)
 
 
;NOTE: page-crossing is pretty much OK for these tables
AreaT1gfx: ;top left icon data
       .byte %11111111
       .byte %10000000
       .byte %10000000
       .byte %10000111
       .byte %10000001
       .byte %10000001
       .byte %10000001
       .byte %10000001
       .byte %10000001
       .byte %10000001
       .byte %10000001
       .byte %10000011
       .byte %10000001
       .byte %10000000
       .byte %10000000
       .byte %11111111
AreaT2gfx:
       .byte %11111111
       .byte %00000001
       .byte %00000001
       .byte %11100001
       .byte %10000001
       .byte %10000001
       .byte %10000001
       .byte %10000001
       .byte %10000001
       .byte %10000001
       .byte %10000001
       .byte %10000001
       .byte %10000001
       .byte %00000001
       .byte %00000001
       .byte %11111111
AreaT1color:
       .byte $1A
       .byte $1A
       .byte $1A
       .byte $1A
       .byte $1A
       .byte $1A
       .byte $1A
       .byte $1A
       .byte $1A
       .byte $1A
       .byte $1A
       .byte $1A
       .byte $1A
       .byte $1A
       .byte $1A
       .byte $1A
 
AreaT3gfx: ;top right icon data
       .byte %11111111
       .byte %10000000
       .byte %10000000
       .byte %10001111
       .byte %10000100
       .byte %10000010
       .byte %10000001
       .byte %10000000
       .byte %10000000
       .byte %10000000
       .byte %10000000
       .byte %10001000
       .byte %10000111
       .byte %10000000
       .byte %10000000
       .byte %11111111
AreaT4gfx:
       .byte %11111111
       .byte %00000001
       .byte %00000001
       .byte %11110001
       .byte %00000001
       .byte %00000001
       .byte %00000001
       .byte %10000001
       .byte %01000001
       .byte %00100001
       .byte %00010001
       .byte %00010001
       .byte %11100001
       .byte %00000001
       .byte %00000001
       .byte %11111111
AreaT2color:
       .byte $3A
       .byte $3A
       .byte $3A
       .byte $3A
       .byte $3A
       .byte $3A
       .byte $3A
       .byte $3A
       .byte $3A
       .byte $3A
       .byte $3A
       .byte $3A
       .byte $3A
       .byte $3A
       .byte $3A
       .byte $3A
 
AreaM1gfx: ;middle left icon data
       .byte %11111111
       .byte %10000000
       .byte %10000000
       .byte %10000111
       .byte %10001000
       .byte %10000000
       .byte %10000000
       .byte %10000000
       .byte %10000001
       .byte %10000000
       .byte %10000000
       .byte %10001000
       .byte %10000111
       .byte %10000000
       .byte %10000000
       .byte %11111111
AreaM2gfx:
       .byte %11111111
       .byte %00000001
       .byte %00000001
       .byte %11100001
       .byte %00010001
       .byte %00010001
       .byte %00010001
       .byte %00010001
       .byte %11100001
       .byte %10000001
       .byte %01000001
       .byte %00100001
       .byte %11110001
       .byte %00000001
       .byte %00000001
       .byte %11111111
AreaM1color:
       .byte $5A
       .byte $5A
       .byte $5A
       .byte $5A
       .byte $5A
       .byte $5A
       .byte $5A
       .byte $5A
       .byte $5A
       .byte $5A
       .byte $5A
       .byte $5A
       .byte $5A
       .byte $5A
       .byte $5A
       .byte $5A
 
AreaM3gfx: ;middle right icon data
       .byte %11111111
       .byte %10000000
       .byte %10000000
       .byte %10000000
       .byte %10000000
       .byte %10000000
       .byte %10001111
       .byte %10000100
       .byte %10000010
       .byte %10000001
       .byte %10000000
       .byte %10000000
       .byte %10000000
       .byte %10000000
       .byte %10000000
       .byte %11111111
AreaM4gfx:
       .byte %11111111
       .byte %00000001
       .byte %00000001
       .byte %00100001
       .byte %00100001
       .byte %00100001
       .byte %11110001
       .byte %00100001
       .byte %00100001
       .byte %00100001
       .byte %10100001
       .byte %00100001
       .byte %00100001
       .byte %00000001
       .byte %00000001
       .byte %11111111
AreaM2color:
       .byte $7A
       .byte $7A
       .byte $7A
       .byte $7A
       .byte $7A
       .byte $7A
       .byte $7A
       .byte $7A
       .byte $7A
       .byte $7A
       .byte $7A
       .byte $7A
       .byte $7A
       .byte $7A
       .byte $7A
       .byte $7A
 
AreaB1gfx: ;bottom left icon data
       .byte %11111111
       .byte %10000000
       .byte %10000000
       .byte %10000111
       .byte %10001000
       .byte %10000000
       .byte %10000000
       .byte %10000000
       .byte %10000000
       .byte %10001111
       .byte %10001000
       .byte %10001000
       .byte %10001111
       .byte %10000000
       .byte %10000000
       .byte %11111111
AreaB2gfx:
       .byte %11111111
       .byte %00000001
       .byte %00000001
       .byte %11100001
       .byte %00010001
       .byte %00010001
       .byte %00010001
       .byte %00010001
       .byte %00010001
       .byte %11100001
       .byte %00000001
       .byte %00000001
       .byte %11110001
       .byte %00000001
       .byte %00000001
       .byte %11111111
AreaB1color:
       .byte $9A
       .byte $9A
       .byte $9A
       .byte $9A
       .byte $9A
       .byte $9A
       .byte $9A
       .byte $9A
       .byte $9A
       .byte $9A
       .byte $9A
       .byte $9A
       .byte $9A
       .byte $9A
       .byte $9A
       .byte $9A
 
AreaB3gfx: ;bottom right icon data
       .byte %11111111
       .byte %10000000
       .byte %10000000
       .byte %10000111
       .byte %10001000
       .byte %10001000
       .byte %10001000
       .byte %10001000
       .byte %10001000
       .byte %10000111
       .byte %10000010
       .byte %10000001
       .byte %10000000
       .byte %10000000
       .byte %10000000
       .byte %11111111
AreaB4gfx:
       .byte %11111111
       .byte %00000001
       .byte %00000001
       .byte %11100001
       .byte %00010001
       .byte %00010001
       .byte %00010001
       .byte %00010001
       .byte %00010001
       .byte %11100001
       .byte %00000001
       .byte %00000001
       .byte %10000001
       .byte %00000001
       .byte %00000001
       .byte %11111111
AreaB2color:
       .byte $BA
       .byte $BA
       .byte $BA
       .byte $BA
       .byte $BA
       .byte $BA
       .byte $BA
       .byte $BA
       .byte $BA
       .byte $BA
       .byte $BA
       .byte $BA
       .byte $BA
       .byte $BA
       .byte $BA
       .byte $BA
  ENDM
 
 
 
  MAC Object_Bitmaps
 
GfxBat1: ;18 bytes, bat's 1st bitmap (states $00-$03)
       .byte %00000000             ; First bitmap value (must be zero)
       .byte $01                   ; First color value (anything *but* zero)
       .byte %10000001 ;X      X   ; Sprite actually begins here...bitmap first...
       .byte $01                   ; ...Then color for that line
       .byte %10000001 ;X      X   ; Continue 2-byte pattern for the rest...
       .byte $01
       .byte %11000011 ;XX    XX
       .byte $01
       .byte %11000011 ;XX    XX
       .byte $01
       .byte %11111111 ;XXXXXXXX
       .byte $01
       .byte %01011010 ; X XX X
       .byte $02
       .byte %01100110 ; XX  XX
       .byte $01
       .byte %00000000             ; Last bitmap value must be zero
       .byte COLOR_DELIMITER ;end  ; ...And last color must be zero
 
GfxWKey: ;10 bytes, key bitmap
       .byte %00000000             ; It's possible to share a delimiter above for this value...
       .byte $0E
       .byte %00000111 ;     XXX
       .byte $0E
       .byte %11111101 ;XXXXXX X
       .byte $0A
       .byte %10100111 ;X X  XXX
       .byte $0E
       .byte %00000000
GfxDot: ;6 bytes, dot bitmap
       .byte COLOR_DELIMITER ;end  ; ...As demonstrated here
       .byte $08
       .byte %10000000 ;X
       .byte $08
GfxNull:                           ; Null sprite requires no graphics...just any double-zero.
       .byte %00000000
       .byte COLOR_DELIMITER ;end
 
;0 bytes free
       ALIGN 256,0
 
GfxGDrag1: ;48 bytes, biting dragon bitmap (states $03-$FF)
       .byte %00000000
       .byte $C8
       .byte %10000000 ;X
       .byte $C8
       .byte %01000000 ; X
       .byte $C8
       .byte %00100110 ;  X  XX
       .byte $C8
       .byte %00011111 ;   XXXXX
       .byte $C8
       .byte %00001011 ;    X XX
       .byte $C8
       .byte %00001110 ;    XXX
       .byte $C8
       .byte %00011110 ;   XXXX
       .byte $C8
       .byte %00100100 ;  X  X
       .byte $C8
       .byte %01000100 ; X   X
       .byte $C8
       .byte %10001110 ;X   XXX
       .byte $C8
       .byte %00011110 ;   XXXX
       .byte $C8
       .byte %00111111 ;  XXXXXX
       .byte $C8
       .byte %01111111 ; XXXXXXX
       .byte $C8
       .byte %01111111 ; XXXXXXX
       .byte $C8
       .byte %01111111 ; XXXXXXX
       .byte $C8
       .byte %01111111 ; XXXXXXX
       .byte $C8
       .byte %00111110 ;  XXXXX
       .byte $C8
       .byte %00011100 ;   XXX
       .byte $C8
       .byte %00001000 ;    X
       .byte $C4
       .byte %11111000 ;XXXXX
       .byte $C4
       .byte %10000000 ;X
       .byte $C4
       .byte %11100000 ;XXX
       .byte $C4
       .byte %00000000
       .byte COLOR_DELIMITER ;end
 
GfxYDrag1: ;48 bytes, biting dragon bitmap (states $03-$FF)
       .byte %00000000
       .byte $1A
       .byte %10000000 ;X
       .byte $1A
       .byte %01000000 ; X
       .byte $1A
       .byte %00100110 ;  X  XX
       .byte $1A
       .byte %00011111 ;   XXXXX
       .byte $1A
       .byte %00001011 ;    X XX
       .byte $1A
       .byte %00001110 ;    XXX
       .byte $1A
       .byte %00011110 ;   XXXX
       .byte $1A
       .byte %00100100 ;  X  X
       .byte $1A
       .byte %01000100 ; X   X
       .byte $1A
       .byte %10001110 ;X   XXX
       .byte $1A
       .byte %00011110 ;   XXXX
       .byte $1A
       .byte %00111111 ;  XXXXXX
       .byte $1A
       .byte %01111111 ; XXXXXXX
       .byte $1A
       .byte %01111111 ; XXXXXXX
       .byte $1A
       .byte %01111111 ; XXXXXXX
       .byte $1A
       .byte %01111111 ; XXXXXXX
       .byte $1A
       .byte %00111110 ;  XXXXX
       .byte $1A
       .byte %00011100 ;   XXX
       .byte $1A
       .byte %00001000 ;    X
       .byte $16
       .byte %11111000 ;XXXXX
       .byte $16
       .byte %10000000 ;X
       .byte $16
       .byte %11100000 ;XXX
       .byte $16
       .byte %00000000
       .byte COLOR_DELIMITER ;end
 
GfxRDrag1: ;48 bytes, biting dragon bitmap (states $03-$FF)
       .byte %00000000
       .byte $38
       .byte %10000000 ;X
       .byte $38
       .byte %01000000 ; X
       .byte $38
       .byte %00100110 ;  X  XX
       .byte $38
       .byte %00011111 ;   XXXXX
       .byte $38
       .byte %00001011 ;    X XX
       .byte $38
       .byte %00001110 ;    XXX
       .byte $38
       .byte %00011110 ;   XXXX
       .byte $38
       .byte %00100100 ;  X  X
       .byte $38
       .byte %01000100 ; X   X
       .byte $38
       .byte %10001110 ;X   XXX
       .byte $38
       .byte %00011110 ;   XXXX
       .byte $38
       .byte %00111111 ;  XXXXXX
       .byte $38
       .byte %01111111 ; XXXXXXX
       .byte $38
       .byte %01111111 ; XXXXXXX
       .byte $38
       .byte %01111111 ; XXXXXXX
       .byte $38
       .byte %01111111 ; XXXXXXX
       .byte $38
       .byte %00111110 ;  XXXXX
       .byte $38
       .byte %00011100 ;   XXX
       .byte $38
       .byte %00001000 ;    X
       .byte $34
       .byte %11111000 ;XXXXX
       .byte $34
       .byte %10000000 ;X
       .byte $34
       .byte %11100000 ;XXX
       .byte $34
       .byte %00000000
       .byte COLOR_DELIMITER ;end
 
 
GfxGDrag2: ;38 bytes, dead dragon bitmap (state $01)
       .byte %00000000
       .byte $C8
       .byte %00001100 ;    XX
       .byte $C8
       .byte %00001100 ;    XX
       .byte $C8
       .byte %00001100 ;    XX
       .byte $C8
       .byte %00001110 ;    XXX
       .byte $C8
       .byte %00011011 ;   XX XX
       .byte $C8
       .byte %01111111 ; XXXXXXX
       .byte $C8
       .byte %11001110 ;XX  XXX
       .byte $C8
       .byte %10000000 ;X
       .byte $46
       .byte %11111100 ;XXXXXX
       .byte $46
       .byte %11111110 ;XXXXXXX
       .byte $C8
       .byte %11111110 ;XXXXXXX
       .byte $C8
       .byte %01111110 ; XXXXXX
       .byte $C8
       .byte %01111000 ; XXXX
       .byte $C8
       .byte %00100000 ;  X
       .byte $C4
       .byte %01101110 ; XX XXX
       .byte $C4
       .byte %01000010 ; X    X
       .byte $C4
       .byte %01111110 ; XXXXXX
       .byte $C4
       .byte %00000000
       .byte COLOR_DELIMITER ;end
 
 
GfxYDrag2: ;38 bytes, dead dragon bitmap (state $01)
       .byte %00000000
       .byte $1A
       .byte %00001100 ;    XX
       .byte $1A
       .byte %00001100 ;    XX
       .byte $1A
       .byte %00001100 ;    XX
       .byte $1A
       .byte %00001110 ;    XXX
       .byte $1A
       .byte %00011011 ;   XX XX
       .byte $1A
       .byte %01111111 ; XXXXXXX
       .byte $1A
       .byte %11001110 ;XX  XXX
       .byte $1A
       .byte %10000000 ;X
       .byte $46
       .byte %11111100 ;XXXXXX
       .byte $46
       .byte %11111110 ;XXXXXXX
       .byte $1A
       .byte %11111110 ;XXXXXXX
       .byte $1A
       .byte %01111110 ; XXXXXX
       .byte $1A
       .byte %01111000 ; XXXX
       .byte $1A
       .byte %00100000 ;  X
       .byte $16
       .byte %01101110 ; XX XXX
       .byte $16
       .byte %01000010 ; X    X
       .byte $16
       .byte %01111110 ; XXXXXX
       .byte $16
       .byte %00000000
       .byte COLOR_DELIMITER ;end
 
 
   IF USE_TITLE_DISPLAY = 0
GfxNum1: ;18 bytes, game selection #1 bitmap (states $00-$01)
       .byte %00000000
       .byte $C8
       .byte %00100000 ;  X
       .byte $38
       .byte %01100000 ; XX
       .byte $3A
       .byte %00100000 ;  X
       .byte $38
       .byte %00100000 ;  X
       .byte $0E
       .byte %00100000 ;  X
       .byte $88
       .byte %00100000 ;  X
       .byte $8A
       .byte %01110000 ; XXX
       .byte $88
       .byte %00000000
       .byte COLOR_DELIMITER ;end
GfxNum2: ;18 bytes, game selection #2 bitmap (states $02-$03)
       .byte %00000000
       .byte $C8
       .byte %01110000 ; XXX
       .byte $CE
       .byte %10001000 ;X   X
       .byte $CC
       .byte %00001000 ;    X
       .byte $CA
       .byte %00010000 ;   X
       .byte $C8
       .byte %00100000 ;  X
       .byte $C6
       .byte %01000000 ; X
       .byte $C4
       .byte %11111000 ;XXXXX
       .byte $C2
       .byte %00000000
       .byte COLOR_DELIMITER ;end
  ELSE
GfxMapPort: ;map portal bitmap
       .byte %00000000
       .byte $01
       .byte %01111110
       .byte $01
       .byte %00000001
       .byte $01
       .byte %00111001
       .byte $01
       .byte %01000101
       .byte $01
       .byte %01010101
       .byte $01
       .byte %01011001
       .byte $01
       .byte %01000001
       .byte $01
       .byte %00111110
       .byte $01
       .byte %00000000
       .byte COLOR_DELIMITER ;end
  ENDIF
 
;0 bytes free
       ALIGN 256,0
 
GfxBKey: ;10 bytes, key bitmap
       .byte %00000000
       .byte $01
       .byte %00000111 ;     XXX
       .byte $01
       .byte %11111101 ;XXXXXX X
       .byte $04
       .byte %10100111 ;X X  XXX
       .byte $01
       .byte %00000000
       .byte COLOR_DELIMITER ;end
 
 
GfxSwordL: ;14 bytes, sword left bitmap
       .byte %00000000
       .byte $1A
       .byte %00100000 ;  X
       .byte $1A
       .byte %01000000 ; X
       .byte $1A
       .byte %11111111 ;XXXXXXXX
       .byte $1A
       .byte %01000000 ; X
       .byte $1A
       .byte %00100000 ;  X
       .byte $1A
       .byte %00000000
       .byte COLOR_DELIMITER ;end
 
 
GfxRDrag2: ;38 bytes, dead dragon bitmap (state $01)
       .byte %00000000
       .byte $38
       .byte %00001100 ;    XX
       .byte $38
       .byte %00001100 ;    XX
       .byte $38
       .byte %00001100 ;    XX
       .byte $38
       .byte %00001110 ;    XXX
       .byte $38
       .byte %00011011 ;   XX XX
       .byte $38
       .byte %01111111 ; XXXXXXX
       .byte $38
       .byte %11001110 ;XX  XXX
       .byte $38
       .byte %10000000 ;X
       .byte $46
       .byte %11111100 ;XXXXXX
       .byte $46
       .byte %11111110 ;XXXXXXX
       .byte $38
       .byte %11111110 ;XXXXXXX
       .byte $38
       .byte %01111110 ; XXXXXX
       .byte $38
       .byte %01111000 ; XXXX
       .byte $38
       .byte %00100000 ;  X
       .byte $34
       .byte %01101110 ; XX XXX
       .byte $34
       .byte %01000010 ; X    X
       .byte $34
       .byte %01111110 ; XXXXXX
       .byte $34
       .byte %00000000
       .byte COLOR_DELIMITER ;end
 
 
GfxAuthor: ;194 bytes, Signature bitmap
       .byte %00000000
       .byte $36
       .byte %11110000 ;XXXX
       .byte $36
       .byte %10000000 ;X
       .byte $36
       .byte %10000000 ;X
       .byte $36
       .byte %10000000 ;X
       .byte $36
       .byte %11110000 ;XXXX
       .byte $36
       .byte %00000100 ;     X
       .byte $0E
       .byte %10000100 ;X    X
       .byte $0E
       .byte %11100111 ;XXX  XXX
       .byte $0E
       .byte %10000101 ;X    X X
       .byte $0E
       .byte %10000111 ;X    XXX
       .byte $0E
       .byte %00000000 ;
       .byte $0E
       .byte %11100101 ;XXX  X X
       .byte $82
       .byte %10100101 ;X X  X X
       .byte $82
       .byte %11100111 ;XXX  XXX
       .byte $82
       .byte %10000001 ;X      X
       .byte $82
       .byte %11100111 ;XXX  XXX
       .byte $82
       .byte %00000000 ;
       .byte $82
       .byte %11100000 ;XXX
       .byte $36
       .byte %10100000 ;X X
       .byte $36
       .byte %11110000 ;XXXX
       .byte $36
       .byte %00000000 ;
       .byte $36
       .byte %01000000 ; X
       .byte $0E
       .byte %11100000 ;XXX
       .byte $0E
       .byte %01000000 ; X
       .byte $0E
       .byte %01000000 ; X
       .byte $0E
       .byte %01000000 ; X
       .byte $0E
       .byte %00000000 ;
       .byte $0E
       .byte %11100000 ;XXX
       .byte $82
       .byte %10100000 ;X X
       .byte $82
       .byte %11100000 ;XXX
       .byte $82
       .byte %10000000 ;X
       .byte $82
       .byte %11100000 ;XXX
       .byte $82
       .byte %00000000 ;
       .byte $82
       .byte %00100000 ;  X
       .byte $36
       .byte %00100000 ;  X
       .byte $36
       .byte %11100000 ;XXX
       .byte $36
       .byte %10100000 ;X X
       .byte $36
       .byte %11100000 ;XXX
       .byte $36
       .byte %00000000 ;
       .byte $36
       .byte %00000000 ;
       .byte $36
       .byte %00000000 ;
       .byte $36
       .byte %00000000 ;
       .byte $36
       .byte %10101000 ;X X X
       .byte $36
       .byte %10101000 ;X X X
       .byte $36
       .byte %10101000 ;X X X
       .byte $36
       .byte %11111000 ;XXXXX
       .byte $36
       .byte %00000000 ;
       .byte $36
       .byte %11100000 ;XXX
       .byte $0E
       .byte %10100000 ;X X
       .byte $0E
       .byte %11110000 ;XXXX
       .byte $0E
       .byte %00000000 ;
       .byte $0E
       .byte %10001111 ;X   XXXX
       .byte $82
       .byte %11101001 ;XXX X  X
       .byte $82
       .byte %10001111 ;X   XXXX
       .byte $82
       .byte %10001010 ;X   X X
       .byte $82
       .byte %00001001 ;    X  X
       .byte $82
       .byte %10000000 ;X
       .byte $36
       .byte %11101110 ;XXX XXX
       .byte $36
       .byte %10001010 ;X   X X
       .byte $36
       .byte %10001010 ;X   X X
       .byte $36
       .byte %00001110 ;    XXX
       .byte $36
       .byte %11100000 ;XXX
       .byte $0E
       .byte %10101000 ;X X X
       .byte $0E
       .byte %11101000 ;XXX X
       .byte $0E
       .byte %10001110 ;X   XXX
       .byte $0E
       .byte %11101010 ;XXX X X
       .byte $0E
       .byte %00001110 ;    XXX
       .byte $0E
       .byte %10000000 ;X
       .byte $82
       .byte %11100100 ;XXX  X
       .byte $82
       .byte %10100100 ;X X  X
       .byte $82
       .byte %10100100 ;X X  X
       .byte $82
       .byte %00000100 ;     X
       .byte $82
       .byte %00000000 ;
       .byte $82
       .byte %00001000 ;    X
       .byte $36
       .byte %00001110 ;    XXX
       .byte $36
       .byte %00001010 ;    X X
       .byte $36
       .byte %00001010 ;    X X
       .byte $36
       .byte %00000000 ;
       .byte $36
       .byte %00001110 ;    XXX
       .byte $0E
       .byte %00001010 ;    X X
       .byte $0E
       .byte %00001110 ;    XXX
       .byte $0E
       .byte %00001000 ;    X
       .byte $0E
       .byte %00001110 ;    XXX
       .byte $0E
       .byte %00000000 ;
       .byte $0E
       .byte %00000100 ;     X
       .byte $82
       .byte %00001110 ;    XXX
       .byte $82
       .byte %00000100 ;     X
       .byte $82
       .byte %00000100 ;     X
       .byte $82
       .byte %00000100 ;     X
       .byte $82
       .byte %00000000 ;
       .byte $82
       .byte %00000100 ;     X
       .byte $36
       .byte %00001110 ;    XXX
       .byte $36
       .byte %00000100 ;     X
       .byte $36
       .byte %00000100 ;     X
       .byte $36
       .byte %00000100 ;     X
       .byte $36
       .byte %00000000
       .byte COLOR_DELIMITER ;end
 
;0 bytes free
       ALIGN 256,0
 
GfxGDrag0: ;44 bytes, roaming/swallowed dragon bitmap (States $00 and $02)
       .byte %00000000
       .byte $C8
       .byte %00000110 ;     XX
       .byte $C8
       .byte %00001111 ;    XXXX
       .byte $C8
       .byte %11110011 ;XXXX  XX
       .byte $C8
       .byte %11111110 ;XXXXXXX
       .byte $C8
       .byte %00001110 ;    XXX
       .byte $C8
       .byte %00000100 ;     X
       .byte $C8
       .byte %00000100 ;     X
       .byte $C8
       .byte %00011110 ;   XXXX
       .byte $C8
       .byte %00111111 ;  XXXXXX
       .byte $C8
       .byte %01111111 ; XXXXXXX
       .byte $C8
       .byte %11100011 ;XXX   XX
       .byte $C8
       .byte %11000011 ;XX    XX
       .byte $C8
       .byte %11000011 ;XX    XX
       .byte $C8
       .byte %11000111 ;XX   XXX
       .byte $C8
       .byte %11111111 ;XXXXXXXX
       .byte $C8
       .byte %00111100 ;  XXXX
       .byte $C8
       .byte %00001000 ;    X
       .byte $C4
       .byte %10001111 ;X   XXXX
       .byte $C4
       .byte %11100001 ;XXX    X
       .byte $C4
       .byte %00111111 ;  XXXXXX
       .byte $C4
       .byte %00000000
       .byte COLOR_DELIMITER ;end
 
GfxYDrag0: ;44 bytes, roaming/swallowed dragon bitmap (States $00 and $02)
       .byte %00000000
       .byte $1A
       .byte %00000110 ;     XX
       .byte $1A
       .byte %00001111 ;    XXXX
       .byte $1A
       .byte %11110011 ;XXXX  XX
       .byte $1A
       .byte %11111110 ;XXXXXXX
       .byte $1A
       .byte %00001110 ;    XXX
       .byte $1A
       .byte %00000100 ;     X
       .byte $1A
       .byte %00000100 ;     X
       .byte $1A
       .byte %00011110 ;   XXXX
       .byte $1A
       .byte %00111111 ;  XXXXXX
       .byte $1A
       .byte %01111111 ; XXXXXXX
       .byte $1A
       .byte %11100011 ;XXX   XX
       .byte $1A
       .byte %11000011 ;XX    XX
       .byte $1A
       .byte %11000011 ;XX    XX
       .byte $1A
       .byte %11000111 ;XX   XXX
       .byte $1A
       .byte %11111111 ;XXXXXXXX
       .byte $1A
       .byte %00111100 ;  XXXX
       .byte $1A
       .byte %00001000 ;    X
       .byte $16
       .byte %10001111 ;X   XXXX
       .byte $16
       .byte %11100001 ;XXX    X
       .byte $16
       .byte %00111111 ;  XXXXXX
       .byte $16
       .byte %00000000
       .byte COLOR_DELIMITER ;end
 
GfxRDrag0: ;44 bytes, roaming/swallowed dragon bitmap (States $00 and $02)
       .byte %00000000
       .byte $38
       .byte %00000110 ;     XX
       .byte $38
       .byte %00001111 ;    XXXX
       .byte $38
       .byte %11110011 ;XXXX  XX
       .byte $38
       .byte %11111110 ;XXXXXXX
       .byte $38
       .byte %00001110 ;    XXX
       .byte $38
       .byte %00000100 ;     X
       .byte $38
       .byte %00000100 ;     X
       .byte $38
       .byte %00011110 ;   XXXX
       .byte $38
       .byte %00111111 ;  XXXXXX
       .byte $38
       .byte %01111111 ; XXXXXXX
       .byte $38
       .byte %11100011 ;XXX   XX
       .byte $38
       .byte %11000011 ;XX    XX
       .byte $38
       .byte %11000011 ;XX    XX
       .byte $38
       .byte %11000111 ;XX   XXX
       .byte $38
       .byte %11111111 ;XXXXXXXX
       .byte $38
       .byte %00111100 ;  XXXX
       .byte $38
       .byte %00001000 ;    X
       .byte $34
       .byte %10001111 ;X   XXXX
       .byte $34
       .byte %11100001 ;XXX    X
       .byte $34
       .byte %00111111 ;  XXXXXX
       .byte $34
       .byte %00000000
       .byte COLOR_DELIMITER ;end
 
 
  IF ANIMATE_DRAGON
GfxGDrag0a: ;42 bytes, roaming/swallowed dragon bitmap (States $00 and $02)
       .byte %00000000 ;
       .byte $C8
       .byte %00000110 ;     XX
       .byte $C8
       .byte %00001111 ;    XXXX
       .byte $C8
       .byte %11110011 ;XXXX  XX
       .byte $C8
       .byte %11111110 ;XXXXXXX
       .byte $C8
       .byte %00001110 ;    XXX
       .byte $C8
       .byte %00000100 ;     X
       .byte $C8
       .byte %00011110 ;   XXXX
       .byte $C8
       .byte %00111111 ;  XXXXXX
       .byte $C8
       .byte %01111111 ; XXXXXXX
       .byte $C8
       .byte %11100011 ;XXX   XX
       .byte $C8
       .byte %11000011 ;XX    XX
       .byte $C8
       .byte %11000011 ;XX    XX
       .byte $C8
       .byte %11000111 ;XX   XXX
       .byte $C8
       .byte %11111111 ;XXXXXXXX
       .byte $C8
       .byte %00111100 ;  XXXX
       .byte $C8
       .byte %00001000 ;    X
       .byte $C4
       .byte %10001111 ;X   XXXX
       .byte $C4
       .byte %11100001 ;XXX    X
       .byte $C4
       .byte %00111111 ;  XXXXXX
       .byte $C4
       .byte %00000000
GfxYDrag0a: ;42 bytes, roaming/swallowed dragon bitmap (States $00 and $02)
       .byte COLOR_DELIMITER ;end
       .byte $1A
       .byte %00000110 ;     XX
       .byte $1A
       .byte %00001111 ;    XXXX
       .byte $1A
       .byte %11110011 ;XXXX  XX
       .byte $1A
       .byte %11111110 ;XXXXXXX
       .byte $1A
       .byte %00001110 ;    XXX
       .byte $1A
       .byte %00000100 ;     X
       .byte $1A
       .byte %00011110 ;   XXXX
       .byte $1A
       .byte %00111111 ;  XXXXXX
       .byte $1A
       .byte %01111111 ; XXXXXXX
       .byte $1A
       .byte %11100011 ;XXX   XX
       .byte $1A
       .byte %11000011 ;XX    XX
       .byte $1A
       .byte %11000011 ;XX    XX
       .byte $1A
       .byte %11000111 ;XX   XXX
       .byte $1A
       .byte %11111111 ;XXXXXXXX
       .byte $1A
       .byte %00111100 ;  XXXX
       .byte $1A
       .byte %00001000 ;    X
       .byte $16
       .byte %10001111 ;X   XXXX
       .byte $16
       .byte %11100001 ;XXX    X
       .byte $16
       .byte %00111111 ;  XXXXXX
       .byte $16
       .byte %00000000
GfxRDrag0a: ;42 bytes, roaming/swallowed dragon bitmap (States $00 and $02)
       .byte COLOR_DELIMITER ;end
       .byte $38
       .byte %00000110 ;     XX
       .byte $38
       .byte %00001111 ;    XXXX
       .byte $38
       .byte %11110011 ;XXXX  XX
       .byte $38
       .byte %11111110 ;XXXXXXX
       .byte $38
       .byte %00001110 ;    XXX
       .byte $38
       .byte %00000100 ;     X
       .byte $38
       .byte %00011110 ;   XXXX
       .byte $38
       .byte %00111111 ;  XXXXXX
       .byte $38
       .byte %01111111 ; XXXXXXX
       .byte $38
       .byte %11100011 ;XXX   XX
       .byte $38
       .byte %11000011 ;XX    XX
       .byte $38
       .byte %11000011 ;XX    XX
       .byte $38
       .byte %11000111 ;XX   XXX
       .byte $38
       .byte %11111111 ;XXXXXXXX
       .byte $38
       .byte %00111100 ;  XXXX
       .byte $38
       .byte %00001000 ;    X
       .byte $34
       .byte %10001111 ;X   XXXX
       .byte $34
       .byte %11100001 ;XXX    X
       .byte $34
       .byte %00111111 ;  XXXXXX
       .byte $34
       .byte %00000000
       .byte COLOR_DELIMITER ;end
  ENDIF
 
;0 bytes free
       ALIGN 256,0
 
    IF ROTATING_SWORD
GfxSwordUL: ;16 bytes, sword up + left bitmap
       .byte %00000000
       .byte $1A
       .byte %01111100 ; XXXXX
       .byte $1A
       .byte %01100000 ; XX
       .byte $1A
       .byte %01010000 ; X X
       .byte $1A
       .byte %01001000 ; X  X
       .byte $1A
       .byte %00000100 ;     X
       .byte $1A
       .byte %00000010 ;      X
       .byte $1A
       .byte %00000000
       .byte COLOR_DELIMITER ;end
 
GfxSwordU: ;18 bytes, sword up bitmap
       .byte %00000000
       .byte $1A
       .byte %00010000 ;   X
       .byte $1A
       .byte %00111000 ;  XXX
       .byte $1A
       .byte %01010100 ; X X X
       .byte $1A
       .byte %00010000 ;   X
       .byte $1A
       .byte %00010000 ;   X
       .byte $1A
       .byte %00010000 ;   X
       .byte $1A
       .byte %00010000 ;   X
       .byte $1A
       .byte %00000000
       .byte COLOR_DELIMITER ;end
 
GfxSwordUR: ;16 bytes, sword up + right bitmap
       .byte %00000000
       .byte $1A
       .byte %01111100 ; XXXXX
       .byte $1A
       .byte %00001100 ;    XX
       .byte $1A
       .byte %00010100 ;   X X
       .byte $1A
       .byte %00100100 ;  X  X
       .byte $1A
       .byte %01000000 ; X
       .byte $1A
       .byte %10000000 ;X
       .byte $1A
       .byte %00000000
       .byte COLOR_DELIMITER ;end
 
 
GfxSwordR: ;14 bytes, sword right bitmap
       .byte %00000000
       .byte $1A
       .byte %00000100 ;     X
       .byte $1A
       .byte %00000010 ;      X
       .byte $1A
       .byte %11111111 ;XXXXXXXX
       .byte $1A
       .byte %00000010 ;      X
       .byte $1A
       .byte %00000100 ;     X
       .byte $1A
       .byte %00000000
       .byte COLOR_DELIMITER ;end
 
GfxSwordDR: ;16 bytes, sword down + right bitmap
       .byte %00000000
       .byte $1A
       .byte %10000000 ;X
       .byte $1A
       .byte %01000000 ; X
       .byte $1A
       .byte %00100100 ;  X  X
       .byte $1A
       .byte %00010100 ;   X X
       .byte $1A
       .byte %00001100 ;    XX
       .byte $1A
       .byte %01111100 ; XXXXX
       .byte $1A
       .byte %00000000
       .byte COLOR_DELIMITER ;end
 
 
GfxSwordD: ;18 bytes, sword down bitmap
       .byte %00000000
       .byte $1A
       .byte %00010000 ;   X
       .byte $1A
       .byte %00010000 ;   X
       .byte $1A
       .byte %00010000 ;   X
       .byte $1A
       .byte %00010000 ;   X
       .byte $1A
       .byte %01010100 ; X X X
       .byte $1A
       .byte %00111000 ;  XXX
       .byte $1A
       .byte %00010000 ;   X
       .byte $1A
       .byte %00000000
       .byte COLOR_DELIMITER ;end
 
GfxSwordDL: ;16 bytes, sword down + left bitmap
       .byte %00000000
       .byte $1A
       .byte %00000010 ;      X
       .byte $1A
       .byte %00000100 ;     X
       .byte $1A
       .byte %01001000 ; X  X
       .byte $1A
       .byte %01010000 ; X X
       .byte $1A
       .byte %01100000 ; XX
       .byte $1A
       .byte %01111100 ; XXXXX
       .byte $1A
       .byte %00000000
       .byte COLOR_DELIMITER ;end
    ENDIF
 
GfxBat2: ;26 bytes, bat's 2nd bitmap (states $04-$FF)
       .byte %00000000
       .byte $01
       .byte %00000000 ;
       .byte $01
       .byte %00000000 ;
       .byte $01
       .byte %00000000 ;
       .byte $01
       .byte %00000000 ;
       .byte $01
       .byte %00111100 ;  XXXX
       .byte $01
       .byte %01011010 ; X XX X
       .byte $02
       .byte %01100110 ; XX  XX
       .byte $01
       .byte %11000011 ;XX    XX
       .byte $01
       .byte %10000001 ;X      X
       .byte $01
       .byte %10000001 ;X      X
       .byte $01
       .byte %10000001 ;X      X
       .byte $01
       .byte %00000000
       .byte COLOR_DELIMITER ;end
 
 
GfxChallise: ;22 bytes, Challise bitmap
       .byte %00000000
       .byte $1C
       .byte %10000001 ;X      X
       .byte $1C
       .byte %10000001 ;X      X
       .byte $1C
       .byte %11000011 ;XX    XX
       .byte $1C
       .byte %01111110 ; XXXXXX
       .byte $1A
       .byte %01111110 ; XXXXXX
       .byte $18
       .byte %00111100 ;  XXXX
       .byte $16
       .byte %00011000 ;   XX
       .byte $0E
       .byte %00011000 ;   XX
       .byte $0E
       .byte %01111110 ; XXXXXX
       .byte $1A
       .byte %00000000
       .byte COLOR_DELIMITER ;end
 
 
   IF USE_TITLE_DISPLAY = 0
GfxNum3: ;18 bytes, game selection #3 bitmap (states $04-$FF)
       .byte %00000000
       .byte $C8
       .byte %01110000 ; XXX
       .byte $C8
       .byte %10001000 ;X   X
       .byte $C4
       .byte %00001000 ;    X
       .byte $C8
       .byte %00110000 ;  XX
       .byte $C4
       .byte %00001000 ;    X
       .byte $C8
       .byte %10001000 ;X   X
       .byte $C4
       .byte %01110000 ; XXX
       .byte $C8
       .byte %00000000
       .byte COLOR_DELIMITER ;end
  ENDIF
 
GfxSurround: ;66 bytes, Surround bitmap
       .byte %00000000
       .byte $20
       .byte %00011000 ;   XX
       .byte $20
       .byte %00111100 ;  XXXX
       .byte $22
       .byte %00111100 ;  XXXX
       .byte $24
       .byte %01111110 ; XXXXXX
       .byte $26
       .byte %01111110 ; XXXXXX
       .byte $28
       .byte %01111110 ; XXXXXX
       .byte $2A
       .byte %11111111 ;XXXXXXXX
       .byte $2C
       .byte %11111111 ;XXXXXXXX
       .byte $2E
       .byte %11111111 ;XXXXXXXX
       .byte $2C
       .byte %11111111 ;XXXXXXXX
       .byte $2A
       .byte %11111111 ;XXXXXXXX
       .byte $28
       .byte %11111111 ;XXXXXXXX
       .byte $2A
       .byte %11111111 ;XXXXXXXX
       .byte $2C
       .byte %11111111 ;XXXXXXXX
       .byte $2E
       .byte %11111111 ;XXXXXXXX
       .byte $2C
       .byte %11111111 ;XXXXXXXX
       .byte $2A
       .byte %11111111 ;XXXXXXXX
       .byte $2C
       .byte %11111111 ;XXXXXXXX
       .byte $2E
       .byte %11111111 ;XXXXXXXX
       .byte $2C
       .byte %11111111 ;XXXXXXXX
       .byte $2A
       .byte %11111111 ;XXXXXXXX
       .byte $28
       .byte %11111111 ;XXXXXXXX
       .byte $2A
       .byte %11111111 ;XXXXXXXX
       .byte $2C
       .byte %11111111 ;XXXXXXXX
       .byte $2E
       .byte %11111111 ;XXXXXXXX
       .byte $2C
       .byte %01111110 ; XXXXXX
       .byte $2A
       .byte %01111110 ; XXXXXX
       .byte $28
       .byte %01111110 ; XXXXXX
       .byte $26
       .byte %00111100 ;  XXXX
       .byte $24
       .byte %00111100 ;  XXXX
       .byte $22
       .byte %00011000 ;   XX
       .byte $20
       .byte %00000000                 ; End of bitmap values...this value should be zero...
       .byte COLOR_DELIMITER ;end      ; ...and followed by zero to tell the kernel it's done.
 
 
GfxYKey: ;10 bytes, key bitmap
       .byte %00000000
       .byte $1A
       .byte %00000111 ;     XXX
       .byte $1A
       .byte %11111101 ;XXXXXX X
       .byte $1C
       .byte %10100111 ;X X  XXX
       .byte $1A
       .byte %00000000
       .byte COLOR_DELIMITER ;end
 
;0 bytes free
       ALIGN 256,0
 
GfxMagnet: ;20 bytes, Magnet bitmap
       .byte %00000000
       .byte $34
       .byte %00111100 ;  XXXX
       .byte $34
       .byte %01111110 ; XXXXXX
       .byte $36
       .byte %11100111 ;XXX  XXX
       .byte $38
       .byte %11000011 ;XX    XX
       .byte $3A
       .byte %11000011 ;XX    XX
       .byte $38
       .byte %11000011 ;XX    XX
       .byte $36
       .byte %11000011 ;XX    XX
       .byte $01
GfxMagnetEnd:
       .byte %11000011 ;XX    XX
       .byte $0E
       .byte %00000000
       .byte COLOR_DELIMITER ;end
 
 
GfxPort01: ;36 bytes, Portcullis bitmap (state $1C...closed)
       .byte %00000000
       .byte $01
       .byte %11111110 ;XXXXXXX
       .byte $01
       .byte %10101010 ;X X X X
       .byte $06
       .byte %11111110 ;XXXXXXX
       .byte $01
       .byte %10101010 ;X X X X
       .byte $06
       .byte %11111110 ;XXXXXXX
       .byte $01
       .byte %10101010 ;X X X X
       .byte $06
       .byte %11111110 ;XXXXXXX
       .byte $01
       .byte %10101010 ;X X X X
       .byte $06
       .byte %11111110 ;XXXXXXX
       .byte $01
       .byte %10101010 ;X X X X
       .byte $06
       .byte %11111110 ;XXXXXXX
       .byte $01
       .byte %10101010 ;X X X X
       .byte $06
       .byte %11111110 ;XXXXXXX
       .byte $01
       .byte %10101010 ;X X X X
       .byte $06
       .byte %11111110 ;XXXXXXX
       .byte $01
       .byte %10101010 ;X X X X
       .byte $06
       .byte %00000000
       .byte COLOR_DELIMITER ;end
 
 
GfxPort02: ;32 bytes, (state $18 and $20)
       .byte %00000000
       .byte $01
       .byte %11111110 ;XXXXXXX
       .byte $01
       .byte %10101010 ;X X X X
       .byte $06
       .byte %11111110 ;XXXXXXX
       .byte $01
       .byte %10101010 ;X X X X
       .byte $06
       .byte %11111110 ;XXXXXXX
       .byte $01
       .byte %10101010 ;X X X X
       .byte $06
       .byte %11111110 ;XXXXXXX
       .byte $01
       .byte %10101010 ;X X X X
       .byte $06
       .byte %11111110 ;XXXXXXX
       .byte $01
       .byte %10101010 ;X X X X
       .byte $06
       .byte %11111110 ;XXXXXXX
       .byte $01
       .byte %10101010 ;X X X X
       .byte $06
       .byte %11111110 ;XXXXXXX
       .byte $01
       .byte %10101010 ;X X X X
       .byte $06
       .byte %00000000
       .byte COLOR_DELIMITER ;end
 
 
GfxPort03: ;28 bytes, (state $14 and $24)
       .byte %00000000
       .byte $01
       .byte %11111110 ;XXXXXXX
       .byte $01
       .byte %10101010 ;X X X X
       .byte $06
       .byte %11111110 ;XXXXXXX
       .byte $01
       .byte %10101010 ;X X X X
       .byte $06
       .byte %11111110 ;XXXXXXX
       .byte $01
       .byte %10101010 ;X X X X
       .byte $06
       .byte %11111110 ;XXXXXXX
       .byte $01
       .byte %10101010 ;X X X X
       .byte $06
       .byte %11111110 ;XXXXXXX
       .byte $01
       .byte %10101010 ;X X X X
       .byte $06
       .byte %11111110 ;XXXXXXX
       .byte $01
       .byte %10101010 ;X X X X
       .byte $06
       .byte %00000000
       .byte COLOR_DELIMITER ;end
 
 
GfxPort04: ;24 bytes, (state $10 and $28)
       .byte %00000000
       .byte $01
       .byte %11111110 ;XXXXXXX
       .byte $01
       .byte %10101010 ;X X X X
       .byte $06
       .byte %11111110 ;XXXXXXX
       .byte $01
       .byte %10101010 ;X X X X
       .byte $06
       .byte %11111110 ;XXXXXXX
       .byte $01
       .byte %10101010 ;X X X X
       .byte $06
       .byte %11111110 ;XXXXXXX
       .byte $01
       .byte %10101010 ;X X X X
       .byte $06
       .byte %11111110 ;XXXXXXX
       .byte $01
       .byte %10101010 ;X X X X
       .byte $06
       .byte %00000000
       .byte COLOR_DELIMITER ;end
 
 
GfxPort05: ;20 bytes, (state $0C and $2C)
       .byte %00000000
       .byte $01
       .byte %11111110 ;XXXXXXX
       .byte $01
       .byte %10101010 ;X X X X
       .byte $06
       .byte %11111110 ;XXXXXXX
       .byte $01
       .byte %10101010 ;X X X X
       .byte $06
       .byte %11111110 ;XXXXXXX
       .byte $01
       .byte %10101010 ;X X X X
       .byte $06
       .byte %11111110 ;XXXXXXX
       .byte $01
       .byte %10101010 ;X X X X
       .byte $06
       .byte %00000000
       .byte COLOR_DELIMITER ;end
 
 
GfxPort06: ;16 bytes, (state $08 and $30)
       .byte %00000000
       .byte $01
       .byte %11111110 ;XXXXXXX
       .byte $01
       .byte %10101010 ;X X X X
       .byte $06
       .byte %11111110 ;XXXXXXX
       .byte $01
       .byte %10101010 ;X X X X
       .byte $06
       .byte %11111110 ;XXXXXXX
       .byte $01
       .byte %10101010 ;X X X X
       .byte $06
       .byte %00000000
       .byte COLOR_DELIMITER ;end
 
 
GfxPort07: ;12 bytes, (state $04 and $FF...open)
       .byte %00000000
       .byte $01
       .byte %11111110 ;XXXXXXX
       .byte $01
       .byte %10101010 ;X X X X
       .byte $06
       .byte %11111110 ;XXXXXXX
       .byte $01
       .byte %10101010 ;X X X X
       .byte $06
       .byte %00000000
       .byte COLOR_DELIMITER ;end
 
GfxBridge: ;52 bytes, bridge bitmap
       .byte %00000000
       .byte $20
       .byte %11000011 ;XX    XX
       .byte $26
       .byte %11000011 ;XX    XX
       .byte $24
       .byte %11000011 ;XX    XX
       .byte $22
       .byte %11000011 ;XX    XX
       .byte $20
       .byte %01000010 ; X    X
       .byte $08
       .byte %01000010 ; X    X
       .byte $01
       .byte %01000010 ; X    X
       .byte $08
       .byte %01000010 ; X    X
       .byte $01
       .byte %01000010 ; X    X
       .byte $08
       .byte %01000010 ; X    X
       .byte $01
       .byte %01000010 ; X    X
       .byte $08
       .byte %01000010 ; X    X
       .byte $01
       .byte %01000010 ; X    X
       .byte $08
       .byte %01000010 ; X    X
       .byte $01
       .byte %01000010 ; X    X
       .byte $08
       .byte %01000010 ; X    X
       .byte $01
       .byte %01000010 ; X    X
       .byte $08
       .byte %01000010 ; X    X
       .byte $01
       .byte %01000010 ; X    X
       .byte $08
       .byte %01000010 ; X    X
       .byte $01
       .byte %11000011 ;XX    XX
       .byte $20
       .byte %11000011 ;XX    XX
       .byte $22
       .byte %11000011 ;XX    XX
       .byte $24
       .byte %11000011 ;XX    XX
       .byte $26
       .byte %00000000
       .byte COLOR_DELIMITER ;end
 
;16 bytes free
    IF SIMULATE_CHALISE_FLASH
       ALIGN 256,0
 
GfxChallise2: ;22 bytes, Challise bitmap
       .byte %00000000
       .byte $3C
       .byte %10000001 ;X      X
       .byte $3C
       .byte %10000001 ;X      X
       .byte $3C
       .byte %11000011 ;XX    XX
       .byte $3C
       .byte %01111110 ; XXXXXX
       .byte $3A
       .byte %01111110 ; XXXXXX
       .byte $38
       .byte %00111100 ;  XXXX
       .byte $36
       .byte %00011000 ;   XX
       .byte $2E
       .byte %00011000 ;   XX
       .byte $2E
       .byte %01111110 ; XXXXXX
       .byte $3A
       .byte %00000000
       .byte COLOR_DELIMITER ;end
 
GfxChallise3: ;22 bytes, Challise bitmap
       .byte %00000000
       .byte $5C
       .byte %10000001 ;X      X
       .byte $5C
       .byte %10000001 ;X      X
       .byte $5C
       .byte %11000011 ;XX    XX
       .byte $5C
       .byte %01111110 ; XXXXXX
       .byte $5A
       .byte %01111110 ; XXXXXX
       .byte $58
       .byte %00111100 ;  XXXX
       .byte $56
       .byte %00011000 ;   XX
       .byte $4E
       .byte %00011000 ;   XX
       .byte $4E
       .byte %01111110 ; XXXXXX
       .byte $5A
       .byte %00000000
       .byte COLOR_DELIMITER ;end
 
GfxChallise4: ;22 bytes, Challise bitmap
       .byte %00000000
       .byte $7C
       .byte %10000001 ;X      X
       .byte $7C
       .byte %10000001 ;X      X
       .byte $7C
       .byte %11000011 ;XX    XX
       .byte $7C
       .byte %01111110 ; XXXXXX
       .byte $7A
       .byte %01111110 ; XXXXXX
       .byte $78
       .byte %00111100 ;  XXXX
       .byte $76
       .byte %00011000 ;   XX
       .byte $6E
       .byte %00011000 ;   XX
       .byte $6E
       .byte %01111110 ; XXXXXX
       .byte $7A
       .byte %00000000
       .byte COLOR_DELIMITER ;end
 
GfxChallise5: ;22 bytes, Challise bitmap
       .byte %00000000
       .byte $9C
       .byte %10000001 ;X      X
       .byte $9C
       .byte %10000001 ;X      X
       .byte $9C
       .byte %11000011 ;XX    XX
       .byte $9C
       .byte %01111110 ; XXXXXX
       .byte $9A
       .byte %01111110 ; XXXXXX
       .byte $98
       .byte %00111100 ;  XXXX
       .byte $96
       .byte %00011000 ;   XX
       .byte $8E
       .byte %00011000 ;   XX
       .byte $8E
       .byte %01111110 ; XXXXXX
       .byte $9A
       .byte %00000000
       .byte COLOR_DELIMITER ;end
 
GfxChallise6: ;22 bytes, Challise bitmap
       .byte %00000000
       .byte $BC
       .byte %10000001 ;X      X
       .byte $BC
       .byte %10000001 ;X      X
       .byte $BC
       .byte %11000011 ;XX    XX
       .byte $BC
       .byte %01111110 ; XXXXXX
       .byte $BA
       .byte %01111110 ; XXXXXX
       .byte $B8
       .byte %00111100 ;  XXXX
       .byte $B6
       .byte %00011000 ;   XX
       .byte $AE
       .byte %00011000 ;   XX
       .byte $AE
       .byte %01111110 ; XXXXXX
       .byte $BA
       .byte %00000000
       .byte COLOR_DELIMITER ;end
 
GfxChallise7: ;22 bytes, Challise bitmap
       .byte %00000000
       .byte $DC
       .byte %10000001 ;X      X
       .byte $DC
       .byte %10000001 ;X      X
       .byte $DC
       .byte %11000011 ;XX    XX
       .byte $DC
       .byte %01111110 ; XXXXXX
       .byte $DA
       .byte %01111110 ; XXXXXX
       .byte $D8
       .byte %00111100 ;  XXXX
       .byte $D6
       .byte %00011000 ;   XX
       .byte $CE
       .byte %00011000 ;   XX
       .byte $CE
       .byte %01111110 ; XXXXXX
       .byte $DA
       .byte %00000000
       .byte COLOR_DELIMITER ;end
 
GfxChallise8: ;22 bytes, Challise bitmap
       .byte %00000000
       .byte $FC
       .byte %10000001 ;X      X
       .byte $FC
       .byte %10000001 ;X      X
       .byte $FC
       .byte %11000011 ;XX    XX
       .byte $FC
       .byte %01111110 ; XXXXXX
       .byte $FA
       .byte %01111110 ; XXXXXX
       .byte $F8
       .byte %00111100 ;  XXXX
       .byte $F6
       .byte %00011000 ;   XX
       .byte $EE
       .byte %00011000 ;   XX
       .byte $EE
       .byte %01111110 ; XXXXXX
       .byte $FA
       .byte %00000000
       .byte COLOR_DELIMITER ;end
    ENDIF
  ENDM
 
  MAC Ball_Enable_Table
;possible to reuse these bytes...so long as bit1 is not needed (ENABL)
BallGFX:
       .byte 0 ;0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0 ;10
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0 ;20
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0 ;30
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0 ;40
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0 ;50
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0 ;60
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0 ;70
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0 ;80
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0 ;90
       .byte 0
       .byte 2 ;display
       .byte 2 ;display
       .byte 2 ;display
       .byte 2 ;display
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0 ;100
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0 ;110
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0 ;120
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0 ;130
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0 ;140
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0 ;150
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0 ;160
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0 ;170
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0 ;180
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
;hiding game select (y=0)...
       .byte 0
       .byte 0
       .byte 0 ;190
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0
       .byte 0 ;200
  ENDM
;end of macro definitions
 
 
 
 
 
 
       SEG rom code
;==============================================================================
;                            START OF FIRST BANK
;==============================================================================
       ORG  $1000
;fill lower part of bank with kernel and game objects
;       Multicolor_Display_Kernel2
       Monocolor_Display_Kernel2
       Object_Bitmaps
;then fill the rest of bank with room GFX (and sprite GFX) specific to that bank's definitions
 
       ALIGN 256,0
 
;NOTE: I left enough space in each page to add color info to each of the (existing) room
;      definitions...if you want to try out the multicolor kernel.  Be wary of page boundries,
;      if you expand the definitions to use less scanlines per band.  Full data lines must not
;      cross page boundries!  Use color change data to cross boundries in Multicolor kernel,
;      or fill remaining 1-3 bytes between data lines if using Monocolor kernel.
 
   IF USE_TITLE_DISPLAY = 0
Room00: ;Number Room Definition
       .byte $F0|REV           ,$FF,$FF,$08 ;XXXXXXXXXXXXXXXXXXXXRRRRRRRRRRRRRRRRRRRR - 8
       .byte $30|REV           ,$00,$00,$50 ;XX                                    RR - 80
       .byte $F0|REV           ,$FF,$0F,$08 ;XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR - 8
  ENDIF
 
Room01: ;Below blue maze
       .byte $F0|REV           ,$FF,$0F,$08 ;XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR - 8
       .byte $00|REV|LP        ,$00,$00,$50 ;  |                                      - 80
       .byte $F0|REV           ,$FF,$FF,$08 ;XXXXXXXXXXXXXXXXXXXXRRRRRRRRRRRRRRRRRRRR - 8
 
 
Room02: ;Below Yellow Castle
       .byte $F0|REV           ,$FF,$0F,$08 ;XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR - 8
       .byte $00|REV           ,$00,$00,$50 ;                                         - 80
       .byte $F0|REV           ,$FF,$FF,$08 ;XXXXXXXXXXXXXXXXXXXXRRRRRRRRRRRRRRRRRRRR - 8
 
 
Room03: ;Above the catacombs
       .byte $F0|REV           ,$FF,$FF,$08 ;XXXXXXXXXXXXXXXXXXXXRRRRRRRRRRRRRRRRRRRR - 8
       .byte $00|REV|RP        ,$00,$00,$50 ;                                     |   - 80
       .byte $F0|REV           ,$FF,$0F,$08 ;XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR - 8
 
Room04: ;Blue Maze, below black castle
       .byte $F0|REV           ,$FF,$0F,$08 ;XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR - 8
       .byte $00|REV           ,$0C,$0C,$10 ;        XX    XX        RR    RR         - 16
       .byte $F0|REV           ,$0C,$3C,$10 ;XXXX    XX    XXXX    RRRR    RR    RRRR - 16
       .byte $F0|REV           ,$0C,$00,$10 ;XXXX    XX                    RR    RRRR - 16
       .byte $F0|REV           ,$FF,$3F,$10 ;XXXXXXXXXXXXXXXXXX    RRRRRRRRRRRRRRRRRR - 16
       .byte $00|REV           ,$30,$30,$10 ;      XX        XX    RR        RR       - 16
       .byte $F0|REV           ,$33,$3F,$08 ;XXXX  XX  XXXXXXXX    RRRRRRRR  RR  RRRR - 8
 
 
Room05: ;Blue Maze, above entry
       .byte $F0|REV           ,$FF,$FF,$08 ;XXXXXXXXXXXXXXXXXXXXRRRRRRRRRRRRRRRRRRRR - 8
       .byte $00|REV           ,$00,$00,$10 ;                                         - 16
       .byte $F0|REV           ,$FC,$FF,$10 ;XXXXXXXXXX  XXXXXXXXRRRRRRRR  RRRRRRRRRR - 16
       .byte $F0|REV           ,$00,$C0,$10 ;XXXX              XXRR              RRRR - 16
       .byte $F0|REV           ,$3F,$CF,$10 ;XXXX  XXXXXXXXXX  XXRR  RRRRRRRRRR  RRRR - 16
       .byte $00|REV           ,$30,$CC,$10 ;      XX      XX  XXRR  RR      RR       - 16
       .byte $F0|REV           ,$F3,$CC,$08 ;XXXXXXXX  XX  XX  XXRR  RR  RR  RRRRRRRR - 8
 
 
Room06: ;Bottom of Blue Maze
       .byte $F0|REV           ,$F3,$0C,$08 ;XXXXXXXX  XX  XX        RR  RR  RRRRRRRR - 8
       .byte $00|REV           ,$30,$0C,$10 ;      XX      XX        RR      RR       - 16
       .byte $F0|REV           ,$3F,$0F,$10 ;XXXX  XXXXXXXXXX        RRRRRRRRRR  RRRR - 16
       .byte $F0|REV           ,$00,$00,$10 ;XXXX                                RRRR - 16
       .byte $F0|REV           ,$F0,$00,$10 ;XXXXXXXX                        RRRRRRRR - 16
       .byte $00|REV           ,$30,$00,$10 ;      XX                        RR       - 16
       .byte $F0|REV           ,$FF,$FF,$08 ;XXXXXXXXXXXXXXXXXXXXRRRRRRRRRRRRRRRRRRRR - 8
 
 
Room07: ;Center of Blue Maze
       .byte $F0|REV           ,$33,$3F,$08 ;XXXX  XX  XXXXXXXX    RRRRRRRR  RR  RRRR - 8
       .byte $00|REV           ,$30,$3C,$10 ;      XX      XXXX    RRRR      RR       - 16
       .byte $F0|REV           ,$FF,$3C,$10 ;XXXXXXXXXXXX  XXXX    RRRR  RRRRRRRRRRRR - 16
       .byte $00|REV           ,$03,$3C,$10 ;          XX  XXXX    RRRR  RR           - 16
       .byte $F0|REV           ,$33,$3C,$10 ;XXXX  XX  XX  XXXX    RRRR  RR  RR  RRRR - 16
       .byte $00|REV           ,$33,$0C,$10 ;      XX  XX  XX        RR  RR  RR       - 16
       .byte $F0|REV           ,$F3,$0C,$08 ;XXXXXXXX  XX  XX        RR  RR  RRRRRRRR - 8
 
 
Room08: ;Blue Maze Entry
       .byte $F0|REV           ,$F3,$CC,$08 ;XXXXXXXX  XX  XX  XXRR  RR  RR  RRRRRRRR - 8
       .byte $00|REV           ,$33,$0C,$10 ;      XX  XX  XX        RR  RR  RR       - 16
       .byte $F0|REV           ,$33,$FC,$10 ;XXXX  XX  XX  XXXXXXRRRRRR  RR  RR  RRRR - 16
       .byte $00|REV           ,$33,$00,$10 ;      XX  XX                RR  RR       - 16
       .byte $F0|REV           ,$F3,$FF,$10 ;XXXXXXXX  XXXXXXXXXXRRRRRRRRRR  RRRRRRRR - 16
       .byte $00|REV           ,$00,$00,$10 ;                                         - 16
       .byte $F0|REV           ,$FF,$0F,$08 ;XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR - 8
 
 
Room0C: ;Right corridor, right of catacombs
       .byte $F0|REV           ,$FF,$0F,$08 ;XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR - 8
       .byte $00|REV|RP        ,$00,$00,$50 ;                                     |   - 80
       .byte $F0|REV           ,$FF,$0F,$08 ;XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR - 8
 
;56 bytes free
       ALIGN 256,0
 
Room09: ;Catacombs Middle
       .byte $F0|REV|HIDE      ,$FF,$CC,$08 ;XXXXXXXXXXXX  XX  XXRR  RR  RRRRRRRRRRRR - 8
       .byte $00|REV|HIDE      ,$00,$CC,$10 ;              XX  XXRR  RR               - 16
       .byte $F0|REV|HIDE      ,$03,$CF,$10 ;XXXX      XXXXXX  XXRR  RRRRRR      RRRR - 16
       .byte $00|REV|HIDE      ,$03,$00,$10 ;          XX                RR           - 16
       .byte $F0|REV|HIDE      ,$F3,$FC,$10 ;XXXXXXXX  XX  XXXXXXRRRRRR  RR  RRRRRRRR - 16
       .byte $00|REV|HIDE      ,$33,$0C,$10 ;      XX  XX  XX        RR  RR  RR       - 16
       .byte $F0|REV|HIDE      ,$33,$CC,$08 ;XXXX  XX  XX  XX  XXRR  RR  RR  RR  RRRR - 8
 
 
Room0A: ;Catacombs Entry
       .byte $F0|REV|HIDE      ,$FF,$0F,$08 ;XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR - 8
       .byte $00|REV|HIDE      ,$30,$00,$10 ;      XX                        RR       - 16
       .byte $F0|REV|HIDE      ,$30,$FF,$10 ;XXXX  XX    XXXXXXXXRRRRRRRRR   RR  RRRR - 16
       .byte $00|REV|HIDE      ,$30,$C0,$10 ;      XX          XXRR          RR       - 16
       .byte $F0|REV|HIDE      ,$F3,$C0,$10 ;XXXXXXXX  XX      XXRR      RR  RRRRRRRR - 16
       .byte $00|REV|HIDE      ,$03,$C0,$10 ;          XX      XXRR      RR           - 16
       .byte $F0|REV|HIDE      ,$FF,$CC,$08 ;XXXXXXXXXXXX  XX  XXRR  RR  RRRRRRRRRRRR - 8
 
 
Room0B: ;Catacombs Side
       .byte $F0|REV|HIDE      ,$33,$CC,$08 ;XXXX  XX  XX  XX  XXRR  RR  RR  RR  RRRR - 8
       .byte $00|REV|HIDE      ,$30,$CC,$10 ;      XX      XX  XXRR  RR      RR       - 16
       .byte $00|REV|HIDE      ,$3F,$CF,$10 ;      XXXXXX  XX  XXRR  RR  RRRRRR       - 16
       .byte $00|REV|HIDE      ,$00,$C0,$10 ;                  XXRR                   - 16
       .byte $00|REV|HIDE      ,$3F,$C3,$10 ;      XXXXXXXX    XXRR    RRRRRRRR       - 16
       .byte $00|REV|HIDE      ,$30,$C0,$10 ;      XX          XXRR          RR       - 16
       .byte $F0|REV|HIDE      ,$FF,$FF,$08 ;XXXXXXXXXXXXXXXXXXXXRRRRRRRRRRRRRRRRRRRR - 8
 
 
Room0D: ;Left corridor, below white castle
       .byte $F0|REV           ,$FF,$0F,$08 ;XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR - 8
       .byte $00|REV|LP        ,$00,$00,$50 ;  |                                      - 80
       .byte $F0|REV           ,$FF,$0F,$08 ;XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR - 8
 
 
Room0E: ;Below left corridor (2 screens below white castle)
       .byte $F0|REV           ,$FF,$0F,$08 ;XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR - 8
       .byte $30|REV           ,$00,$00,$50 ;XX                                    RR - 80
       .byte $F0|REV           ,$FF,$FF,$08 ;XXXXXXXXXXXXXXXXXXXXRRRRRRRRRRRRRRRRRRRR - 8
 
 
Room0F: ;White Castle (outside)
       .byte $F0|REV           ,$FE,$15,$08 ;XXXXXXXXXXX X X X      R R R RRRRRRRRRRR - 8
       .byte $30|REV           ,$03,$1F,$10 ;XX        XXXXXXX      RRRRRRR        RR - 16
       .byte $30|REV           ,$03,$FF,$10 ;XX        XXXXXXXXXXRRRRRRRRRR        RR - 16
       .byte $30|REV           ,$00,$FF,$10 ;XX          XXXXXXXXRRRRRRRR          RR - 16
       .byte $30|REV           ,$00,$3F,$10 ;XX          XXXXXX    RRRRRR          RR - 16
       .byte $30|REV           ,$00,$00,$10 ;XX                                    RR - 16
       .byte $F0|REV           ,$FF,$0F,$08 ;XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR - 8
 
 
Room10: ;Black Castle (outside)
       .byte $F0|REV           ,$FE,$15,$08 ;XXXXXXXXXXX X X X      R R R RRRRRRRRRRR - 8
       .byte $30|REV           ,$03,$1F,$10 ;XX        XXXXXXX      RRRRRRR        RR - 16
       .byte $30|REV           ,$03,$FF,$10 ;XX        XXXXXXXXXXRRRRRRRRRR        RR - 16
       .byte $30|REV           ,$00,$FF,$10 ;XX          XXXXXXXXRRRRRRRR          RR - 16
       .byte $30|REV           ,$00,$3F,$10 ;XX          XXXXXX    RRRRRR          RR - 16
       .byte $30|REV           ,$00,$00,$10 ;XX                                    RR - 16
       .byte $F0|REV           ,$FF,$0F,$08 ;XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR - 8
 
 
Room12: ;Inside Yellow castle
       .byte $F0|REV           ,$FF,$FF,$08 ;XXXXXXXXXXXXXXXXXXXXRRRRRRRRRRRRRRRRRRRR - 8
       .byte $30|REV           ,$00,$00,$50 ;XX                                    RR - 80
       .byte $F0|REV           ,$FF,$0F,$08 ;XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR - 8
 
 
Room1B: ;Just inside the black castle
       .byte $F0|REV           ,$FF,$0F,$08 ;XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR - 8
       .byte $30|REV           ,$00,$00,$50 ;XX                                    RR - 80
       .byte $F0|REV           ,$FF,$0F,$08 ;XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR - 8
 
 
Room1C: ;Above right corridor (#1 - 2nd room in black castle, #2/#3 - right of catacombs)
       .byte $F0|REV           ,$FF,$FF,$08 ;XXXXXXXXXXXXXXXXXXXXRRRRRRRRRRRRRRRRRRRR - 8
       .byte $30|REV           ,$00,$00,$50 ;XX                                    RR - 80
       .byte $F0|REV           ,$FF,$0F,$08 ;XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR - 8
 
;56 bytes free
       ALIGN 256,0
 
Room11: ;Yellow Castle (outside)
       .byte $F0|REV           ,$FE,$15,$08 ;XXXXXXXXXXX X X X      R R R RRRRRRRRRRR - 8
       .byte $30|REV           ,$03,$1F,$10 ;XX        XXXXXXX      RRRRRRR        RR - 16
       .byte $30|REV           ,$03,$FF,$10 ;XX        XXXXXXXXXXRRRRRRRRRR        RR - 16
       .byte $30|REV           ,$00,$FF,$10 ;XX          XXXXXXXXRRRRRRRR          RR - 16
       .byte $30|REV           ,$00,$3F,$10 ;XX          XXXXXX    RRRRRR          RR - 16
       .byte $30|REV           ,$00,$00,$10 ;XX                                    RR - 16
       .byte $F0|REV           ,$FF,$0F,$08 ;XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR - 8
 
 
Room13: ;Black Maze, right from entry
       .byte $F0|REV|HIDE      ,$F0,$FF,$08 ;XXXXXXXX    XXXXXXXXRRRRRRRR    RRRRRRRR - 8
       .byte $00|REV|HIDE      ,$00,$03,$10 ;            XX            RR             - 16
       .byte $F0|REV|HIDE      ,$FF,$03,$10 ;XXXXXXXXXXXXXX            RRRRRRRRRRRRRR - 16
       .byte $00|REV|HIDE      ,$00,$00,$10 ;                                         - 16
       .byte $30|REV|HIDE      ,$3F,$FF,$10 ;XX    XXXXXXXXXXXXXXRRRRRRRRRRRRRR    RR - 16
       .byte $00|REV|HIDE      ,$30,$00,$10 ;      XX                        RR       - 16
       .byte $F0|REV|HIDE      ,$F0,$FF,$08 ;XXXXXXXX    XXXXXXXXRRRRRRRR    RRRRRRRR - 8
 
 
Room14: ;Black Maze, Challise room
       .byte $F0|HIDE          ,$FF,$FF,$08 ;XXXXXXXXXXXXXXXXXXXXMMMMMMMMMMMMMMMMMMMM - 8
       .byte $00|HIDE          ,$00,$C0,$10 ;                  XX                  MM - 16
       .byte $F0|HIDE          ,$FF,$CF,$10 ;XXXXXXXXXXXXXXXX  XXMMMMMMMMMMMMMMMM  MM - 16
       .byte $00|HIDE          ,$00,$0C,$10 ;              XX                  MM     - 16
       .byte $F0|HIDE          ,$0F,$FF,$10 ;XXXX    XXXXXXXXXXXXMMMM    MMMMMMMMMMMM - 16
       .byte $00|HIDE          ,$0F,$C0,$10 ;        XXXX      XX        MMMM      MM - 16
       .byte $30|HIDE          ,$CF,$CC,$08 ;XX  XX  XXXX  XX  XXMM  MM  MMMM  MM  MM - 8
 
 
Room15: ;Black Maze, Dot's room
       .byte $F0|HIDE          ,$F0,$FF,$08 ;XXXXXXXX    XXXXXXXXMMMMMMMM    MMMMMMMM - 8
       .byte $30|HIDE          ,$00,$00,$10 ;XX                  MM                   - 16
       .byte $30|HIDE          ,$3F,$FF,$10 ;XX    XXXXXXXXXXXXXXMM    MMMMMMMMMMMMMM - 16
       .byte $00|HIDE          ,$30,$00,$10 ;      XX                  MM             - 16
       .byte $F0|HIDE          ,$F0,$FF,$10 ;XXXXXXXX    XXXXXXXXMMMMMMMM    MMMMMMMM - 16
       .byte $30|HIDE          ,$00,$03,$10 ;XX          XX     .MM          MM       - 16
       .byte $F0|HIDE          ,$F0,$FF,$08 ;XXXXXXXX    XXXXXXXXMMMMMMMM    MMMMMMMM - 8
 
 
Room16: ;Black Maze Entry
       .byte $30|REV|HIDE      ,$CF,$CC,$08 ;XX  XX  XXXX  XX  XXRR  RR  RRRR  RR  RR - 8
       .byte $00|REV|HIDE      ,$C0,$CC,$10 ;    XX        XX  XXRR  RR        RR     - 16
       .byte $F0|REV|HIDE      ,$FF,$0F,$10 ;XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR - 16
       .byte $00|REV|HIDE      ,$00,$00,$10 ;                                         - 16
       .byte $F0|REV|HIDE      ,$FF,$0F,$10 ;XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR - 16
       .byte $00|REV|HIDE      ,$00,$00,$10 ;                                         - 16
       .byte $F0|REV|HIDE      ,$FF,$0F,$08 ;XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR - 8
 
 
Room17: ;Red Maze, above black key's room
       .byte $F0|REV           ,$FF,$FF,$08 ;XXXXXXXXXXXXXXXXXXXXRRRRRRRRRRRRRRRRRRRR - 8
       .byte $00|REV           ,$00,$00,$10 ;                                         - 16
       .byte $F0|REV           ,$FF,$0F,$10 ;XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR - 16
       .byte $00|REV           ,$00,$0C,$10 ;              XX        RR               - 16
       .byte $F0|REV           ,$FF,$0C,$10 ;XXXXXXXXXXXX  XX        RR  RRRRRRRRRRRR - 16
       .byte $F0|REV           ,$03,$CC,$10 ;XXXX      XX  XX  XXRR  RR  RR      RRRR - 16
       .byte $F0|REV           ,$33,$CF,$08 ;XXXX  XX  XXXXXX  XXRR  RRRRRR  RR  RRRR - 8
 
 
Room18: ;Red Maze, above entry
       .byte $F0|REV           ,$FF,$FF,$08 ;XXXXXXXXXXXXXXXXXXXXRRRRRRRRRRRRRRRRRRRR - 8
       .byte $00|REV           ,$00,$C0,$10 ;                  XXRR                   - 16
       .byte $F0|REV           ,$FF,$CF,$10 ;XXXXXXXXXXXXXXXX  XXRR  RRRRRRRRRRRRRRRR - 16
       .byte $00|REV           ,$00,$CC,$10 ;              XX  XXRR  RR               - 16
       .byte $F0|REV           ,$33,$FF,$10 ;XXXX  XX  XXXXXXXXXXRRRRRRRRRR  RR  RRRR - 16
       .byte $F0|REV           ,$33,$00,$10 ;XXXX  XX  XX                RR  RR  RRRR - 16
       .byte $F0|REV           ,$3F,$0C,$08 ;XXXX  XXXXXX  XX        RR  RRRRRR  RRRR - 8
 
;60 bytes free
       ALIGN 256,0
 
Room19: ;Red Maze, black key's room
       .byte $F0|REV           ,$33,$CF,$08 ;XXXX  XX  XXXXXX  XXRR  RRRRRR  RR  RRRR - 8
       .byte $F0|REV           ,$30,$00,$10 ;XXXX  XX                        RR  RRRR - 16
       .byte $F0|REV           ,$33,$FF,$10 ;XXXX  XX  XXXXXXXXXXRRRRRRRRRR  RR  RRRR - 16
       .byte $00|REV           ,$33,$00,$10 ;      XX  XX                RR  RR  RRRR - 16
       .byte $F0|REV           ,$FF,$00,$10 ;XXXXXXXXXXXX                RRRRRRRRRRRR - 16
       .byte $00|REV           ,$00,$00,$10 ;                                         - 16
       .byte $F0|REV           ,$FF,$0F,$08 ;XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR - 8
 
 
Room1A: ;Red Maze Entry
       .byte $F0|REV           ,$3F,$0C,$08 ;XXXX  XXXXXX  XX        RR  RRRRRR  RRRR - 8
       .byte $F0|REV           ,$00,$0C,$10 ;XXXX          XX        RR          RRRR - 16
       .byte $F0|REV           ,$FF,$0F,$10 ;XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR - 16
       .byte $00|REV           ,$30,$00,$10 ;      XX                        RR       - 16
       .byte $F0|REV           ,$30,$00,$10 ;XXXX  XX                        RR  RRRR - 16
       .byte $00|REV           ,$30,$00,$10 ;      XX                        RR       - 16
       .byte $F0|REV           ,$FF,$0F,$08 ;XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR - 8
 
 
Room1D: ;Below right corridor (below right panel room - #1, right of catacombs - #2/#3)
       .byte $F0|REV           ,$FF,$0F,$08 ;XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR - 8
       .byte $30|REV           ,$00,$00,$50 ;XX                                    RR - 80
       .byte $F0|REV           ,$FF,$FF,$08 ;XXXXXXXXXXXXXXXXXXXXRRRRRRRRRRRRRRRRRRRR - 8
 
 
Room1E: ;Warren Robinett's room
       .byte $F0|REV           ,$FF,$0F,$08 ;XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR - 8
       .byte $00|REV           ,$00,$00,$50 ;                                         - 80
       .byte $F0|REV           ,$FF,$FF,$08 ;XXXXXXXXXXXXXXXXXXXXRRRRRRRRRRRRRRRRRRRR - 8
 
 
;Set these wherever you want!
   IF USE_TITLE_DISPLAY
       Titlescreen
       MapScreen
   ENDIF
 
 
  IF BANKS = 0
       ORG  $1F2F,0
       RORG $1F2F
       Ball_Enable_Table
       ORG  $1FF8,0
       RORG $1FF8
       .byte "3911"
  ENDIF
  IF BANKS = 1
       ORG  $1F2D,0
       RORG $1F2D
       Ball_Enable_Table
       ORG  $1FF6,0
       RORG $1FF6
       .byte "3/9/11"
  ENDIF
  IF BANKS = 2
       ORG  $1F2B,0
       RORG $1F2B
       Ball_Enable_Table
       ORG  $1FF4,0
       RORG $1FF4
       .byte "3/9/2011"
  ENDIF
       .word START ;cold start vector
       .word START ;interrupt vector
;==============================================================================
;                              END OF FIRST BANK
;==============================================================================
 
 
 
 
 
 
 
 
;Second & Third for 16K or 32K
  IF BANKS
;==============================================================================
;                             START OF SECOND BANK
;==============================================================================
       ORG  $2000
       RORG $1000
;fill lower part of bank with kernel and game objects
;       Multicolor_Display_Kernel2
       Monocolor_Display_Kernel2
       Object_Bitmaps
;then fill the rest of bank with room GFX (and sprite GFX) specific to that bank's definitions
 
    IF BANKS = 1
       ORG  $2F2D,0
       RORG $1F2D
       Ball_Enable_Table
       ORG  $2FF6,0
       RORG $1FF6
       .byte "3/9/11"
    ELSE
       ORG  $2F2B,0
       RORG $1F2B
       Ball_Enable_Table
       ORG  $2FF4,0
       RORG $1FF4
       .byte "3/9/2011"
    ENDIF
       .word START ;cold start vector
       .word START ;interrupt vector
;==============================================================================
;                             END OF SECOND BANK
;==============================================================================
 
 
 
 
 
;==============================================================================
;                             START OF THIRD BANK
;==============================================================================
       ORG  $3000
       RORG $1000
;fill lower part of bank with kernel and game objects
;       Multicolor_Display_Kernel2
       Monocolor_Display_Kernel2
       Object_Bitmaps
;then fill the rest of bank with room GFX (and sprite GFX) specific to that bank's definitions
 
    IF BANKS = 1
       ORG  $3F2D,0
       RORG $1F2D
       Ball_Enable_Table
       ORG  $3FF6,0
       RORG $1FF6
       .byte "3/9/11"
    ELSE
       ORG  $3F2B,0
       RORG $1F2B
       Ball_Enable_Table
       ORG  $3FF4,0
       RORG $1FF4
       .byte "3/9/2011"
    ENDIF
       .word START ;cold start vector
       .word START ;interrupt vector
;==============================================================================
;                             END OF THIRD BANK
;==============================================================================
  ENDIF
 
 
 
 
 
 
 
 
 
;Fourth thru Seventh for 32K only
  IF BANKS = 2
;==============================================================================
;                             START OF FOURTH BANK
;==============================================================================
       ORG  $4000
       RORG $1000
;fill lower part of bank with kernel and game objects
;       Multicolor_Display_Kernel2
       Monocolor_Display_Kernel2
       Object_Bitmaps
;then fill the rest of bank with room GFX (and sprite GFX) specific to that bank's definitions
 
       ORG  $4F2B,0
       RORG $1F2B
       Ball_Enable_Table
       ORG  $4FF4,0
       RORG $1FF4
       .byte "3/9/2011"
       .word START ;cold start vector
       .word START ;interrupt vector
;==============================================================================
;                             END OF FOURTH BANK
;==============================================================================
 
 
;==============================================================================
;                             START OF FIFTH BANK
;==============================================================================
       ORG  $5000
       RORG $1000
;fill lower part of bank with kernel and game objects
;       Multicolor_Display_Kernel2
       Monocolor_Display_Kernel2
       Object_Bitmaps
;then fill the rest of bank with room GFX (and sprite GFX) specific to that bank's definitions
 
       ORG  $5F2B,0
       RORG $1F2B
       Ball_Enable_Table
       ORG  $5FF4,0
       RORG $1FF4
       .byte "3/9/2011"
       .word START ;cold start vector
       .word START ;interrupt vector
;==============================================================================
;                             END OF FIFTH BANK
;==============================================================================
 
 
 
;==============================================================================
;                             START OF SIXTH BANK
;==============================================================================
       ORG  $6000
       RORG $1000
;fill lower part of bank with kernel and game objects
;       Multicolor_Display_Kernel2
       Monocolor_Display_Kernel2
       Object_Bitmaps
;then fill the rest of bank with room GFX (and sprite GFX) specific to that bank's definitions
 
       ORG  $6F2B,0
       RORG $1F2B
       Ball_Enable_Table
       ORG  $6FF4,0
       RORG $1FF4
       .byte "3/9/2011"
       .word START ;cold start vector
       .word START ;interrupt vector
;==============================================================================
;                             END OF SIXTH BANK
;==============================================================================
 
 
 
;==============================================================================
;                             START OF SEVENTH BANK
;==============================================================================
       ORG  $7000
       RORG $1000
;fill lower part of bank with kernel and game objects
;       Multicolor_Display_Kernel2
       Monocolor_Display_Kernel2
       Object_Bitmaps
;then fill the rest of bank with room GFX (and sprite GFX) specific to that bank's definitions
 
       ORG  $7F2B,0
       RORG $1F2B
       Ball_Enable_Table
       ORG  $7FF4,0
       RORG $1FF4
       .byte "3/9/2011"
       .word START ;cold start vector
       .word START ;interrupt vector
;==============================================================================
;                             END OF SEVENTH BANK
;==============================================================================
  ENDIF
 
 
 
 
 
 
 
 
 
 
 
 
 
 
;==============================================================================
;                             START OF LAST BANK
;==============================================================================
  IF BANKS = 0
       ORG  $2000
       RORG $F000
START:
       lda    $FFF9               ;4
       jmp    StartGame           ;3 Go to cold start routine in last bank
    IF USE_TITLE_DISPLAY
TitleBankswitch:
       lda    $FFF8               ;4 Select first bank
       jmp    TitleReturn         ;3 72
MapBankswitch:
       lda    $FFF8               ;4 Select first bank
       jmp    MapReturn           ;3 72
    ENDIF
Kernel: ;43
       lda    $FFF8               ;4 47
  ENDIF
 
 
  IF BANKS = 1
       ORG  $4000
       RORG $F000
START:
       lda    $FFF9               ;4
       jmp    StartGame           ;3 Go to cold start routine in last bank
    IF USE_TITLE_DISPLAY
TitleBankswitch:
       lda    $FFF6,y             ;4 Select bank number (Y)
       jmp    TitleReturn         ;3 72
MapBankswitch:
       lda    $FFF6,y             ;4 Select bank number (Y)
       jmp    MapReturn           ;3 72
    ENDIF
Kernel: ;43
       lda    $FFF6,y             ;4 47 Select bank number (Y)
  ENDIF
 
 
  IF BANKS = 2
       ORG  $8000
       RORG $F000
START:
       lda    $FFFB               ;4
       jmp    StartGame           ;3 Go to cold start routine in last bank
    IF USE_TITLE_DISPLAY
TitleBankswitch:
       lda    $FFF4,y             ;4 Select bank number (Y)
       jmp    TitleReturn         ;3 72
MapBankswitch:
       lda    $FFF4,y             ;4 Select bank number (Y)
       jmp    MapReturn           ;3 72
    ENDIF
Kernel: ;43
       lda    $FFF4,y             ;4 47 Select bank number (Y)
  ENDIF
 
 
;59 from first bank, X=0
       ldy    $FC                 ;3 62
       sty    Obj2Lo              ;3 65
       ldy    $FD                 ;3 68
       sty.w  Obj1Lo              ;4 72
TitleReturn: ;72
MapReturn: ;72
       txa                        ;2 74
       ldx    #$02                ;2 76
;-----------------------------------
       stx    VBLANK              ;3 03 Turn on VBLANK
       ldx    #$FD                ;2
       txs                        ;2
       sta    ENABL               ;3 Clear all sprites
       sta    GRP0                ;3 .
       sta    GRP1                ;3 .
       lda    #TIME1              ;2 Set overscan time
       bne    Store_Timer         ;2 Always branch (save timer and return)
 
 
DoVSYNC: ;Perform VSYNC
DoVSYNC_2:
       ldx    INTIM               ;4 Get Timer Output
       bne    DoVSYNC_2           ;2 Wait for Time-Out
       lda    #$02                ;2 (enable)
       sta    WSYNC               ;3 Wait for horizontal Blank
       sta    VSYNC               ;3 Start vertical sync
       sta    WSYNC               ;3 Wait for horizontal Blank
       stx    VSYNC               ;3 End vertical sync
       lda    #TIME2              ;2 Set clock interval to countdown next frame
Store_Timer:
       sta    TIM64T              ;4
       rts                        ;6
 
 
 
PrintDisplay: ;draw a frame...
 
  IF UNROLL_POSITIONING
;Position ball horizontally.
       lda    PlayerX             ;3 Position Ball Strite to the X Coordinate (all frames)
       ldx    #$00                ;2
       sec                        ;2
PosBall_1:
       inx                        ;2 Divide the Coordinate wanted by fifteen
       sbc    #$0F                ;2 Get Course Horizontal Value...In Multiples of 5 Clock
       bcs    PosBall_1           ;2 Cycles...(Therefore giving 15 Color Cycles)
       eor    #$FF                ;2 Flip remainder to positive value (inverted)
       sbc    #$06                ;2 Convert to left or right of current position
       sta    WSYNC               ;3 Wait for horizontal Blank
       asl                        ;2 Move to high nybble for TIA horizontal motion...
       asl                        ;2 .
       asl                        ;2 .
       asl                        ;2 .
PosBall_2:
       dex                        ;2 Count down the color cycles...
       bpl    PosBall_2           ;2 These are 5 machine/15 color cycles
       sta    HMBL                ;3 Set horizontal (fine) motion of sprite
       sta    RESBL               ;3 Reset the sprite, thus positioning it coursely
       inx                        ;2 X=0
  ELSE
       lda    PlayerX             ;3 Position Ball Strite to the X Coordinate (all frames)
       ldx    #$04                ;2 Select sprite #5 (ball)
       jsr    PosSpriteX          ;6 Execute repositioning subroutine
  ENDIF
       lda    Control             ;3 Get 3-frame room number
       and    #$7F                ;2 Strip inactive game bit
       tay                        ;2 ...and pass to Y for an index
       lda    Obj1Lo              ;3 Transfer low sprite0 pointer to stack
       pha                        ;3
       lda    Obj2Lo              ;3 Transfer low sprite1 pointer to stack
       pha                        ;3
       lda    #>BallGFX           ;2
       sta    Ball+1              ;3
       lda    RoomGFX_LSB_Tbl,y   ;4 Get the room gfx LSB pointer
       sta    RoomLo              ;3 ...And store
       lda    PlayerY             ;3 Get the Y Coordinate of the ball
       cmp    #$68                ;2 Check if on top 2 scanlines
       bcc    Ball_Lower_Than_Top ;2 Branch if not
       ldx    #$02                ;2 Otherwise...enable the ball immediately
Ball_Lower_Than_Top:
       stx    ENABL               ;3
       lda    #<BallGFX+105       ;2
PrintDisplay_1:
       ldx    INTIM               ;4 Wait for end of the current frame
       bne    PrintDisplay_1      ;2
       sta    WSYNC               ;3 Wait for horizontal Blank
;-----------------------------------
       sta    HMOVE               ;3 03 Apply Horizontal Motion
       sec                        ;2 05
       sbc    PlayerY             ;3 08 Get the Y Coordinate of the ball
       sta    Ball                ;3 11
       lda    RoomGFX_MSB_Tbl,y   ;4 15 Get the room gfx MSB pointer
       ora    #SURROUND           ;2 17 Ignore "SURROUND" flag, set to MSB to ROM instead
       sta    RoomHi              ;3 20 ...And store
       rol                        ;2 22
       rol                        ;2 24
       rol                        ;2 26
       rol                        ;2 28
       and    #BANK_SELECT        ;2 30
       tay                        ;2 32 ...And give to Y for bank # where room GFX exists
       ldx    #$60                ;2 34 Set to start displaying playfield
       sta    CXCLR               ;3 37 Clear Collision Latches
       sta    HMCLR               ;3 40 Clear horizontal motion
       jmp    Kernel              ;3 43
 
 
 
 
CacheObjects: ;Fill cache with two objects in this room.
       ldx    LastObj             ;3 Get Last Object
       ldy    #NullNumber         ;2 Set cache to no objects (zero) / also use as (Ind),y ptr
       sty    CurrentObject+2     ;3 .
       sty    CurrentObject+3     ;3 .
MoveNextObject:
       dex                        ;2 Goto the next object
       bne    GetObjectsInfo      ;2 Branch if all objects not checked
       ldx    #LastObjectNumber   ;2 Otherwise, reset to the last sprite object
GetObjectsInfo:
       lda    Object_Data_LSB,x   ;4 Get low byte of object info
       sta    CurrentObject       ;3 ...And store
       lda    Object_Data_MSB,x   ;4 Get high byte of object info
       sta    CurrentObject+1     ;3 ...And store
       lda    (CurrentObject),y   ;5 Get object's current room
       cmp    PlayerRoom          ;3 Is it in this room?
       bne    CheckForMoreObjects ;2 If not, try next object
       lda    CurrentObject+2     ;3 Check first slot
       bne    StoreObjectToPrint  ;2 If not free then branch
       stx    CurrentObject+2     ;3 Store this object's number to print
CheckForMoreObjects:
       cpx    LastObj             ;3 Have we done all the objects?
       bne    MoveNextObject      ;2 If not, continue
       beq    StoreCount          ;2 Always branch
 
StoreObjectToPrint:
       stx    CurrentObject+3     ;3 Store this object's number to print
StoreCount:
       stx    LastObj             ;3 If so, store current count for next time
SetupRoomPrint: ;Setup a room for print
       lda    Control             ;3
       and    #$80                ;2
       ora    PlayerRoom          ;3 Create a backup of the room number for 3 frames
       sta    Control             ;3 ...So that it does not need setting up each time
       ldy    PlayerRoom          ;3 Get current room number
       lda    Wall_Color_Tbl,y    ;4 Get the room's foreground color
       jsr    ChangeColor         ;6 Change if necessary
       sta    COLUPF              ;3 Put it in the foreground color register
  IF USE_UNIQUE_BACKGROUND_COLORS
       lda    Ground_Color_Tbl,y  ;4 Get the room's background color
       jsr    ChangeColor         ;6 Change if necessary
  ELSE
       lda    #$04                ;2 Get light grey background (all rooms)
       jsr    ChangeColor_2       ;6 Change if necessary (ASL at end moves it to color $08)
  ENDIF
       sta    COLUBK              ;3 Put it in the Background color register
;Sort out their order...do 1st sprite...
       lda    CurrentObject+2     ;3 Check first object
       cmp    #SurroundNumber     ;2 If the first object is the surround...
       beq    SwapPrintObjects    ;2 Then branch to swap (we want it as player01)
       cmp    #BridgeNumber       ;2 If the first object is the bridge...
       bne    SetupObjectPrint    ;2 Then swap the objects (we want it as player01)
       lda    CurrentObject+3     ;3 Check object2
       cmp    #SurroundNumber     ;2 If object2 is the surround...
       beq    SetupObjectPrint    ;2 branch (we want it as player01)
SwapPrintObjects:
       lda    CurrentObject+2     ;3 Swap the objects to print
       ldx    CurrentObject+3     ;3 .
       sta    CurrentObject+3     ;3 .
       stx    CurrentObject+2     ;3 .
SetupObjectPrint:
       ldx    CurrentObject+2     ;3 Setup Object1 to print...get Object 1
       lda    BatR+4              ;3
       sta    BatStateBackup      ;3 Save as backup
       and    #$07                ;2 Ignore bits 7-3
       sta    BatR+4              ;3
       lda    Object_Data_LSB,x   ;4 Get low pointer to it's dynamic information
       sta    CurrentObject       ;3 ...Store
       lda    Object_Data_MSB,x   ;4 Get high pointer to it's dynamic informtion
       sta    CurrentObject+1     ;3 ...Store
       rol                        ;2 Move upper 3 bits to low position for sprite width
       rol                        ;2 .
       rol                        ;2 .
       rol                        ;2 .
       and    #$07                ;2 Trim to only those 3 bits
       ora    #$10                ;2 Value to include width of corresponding missile sprite
       sta    NUSIZ0              ;3 Update
       ldy    #$01                ;2 Set initial Y index
       lda    (CurrentObject),y   ;5 Get Object1's horizontal co-ordinate
  IF UNROLL_POSITIONING
       sta    Temp                ;3 ...And store for printing
  ENDIF
       sta    ObjX                ;3 (Also save as current)
       iny                        ;2 Bump index
       lda    (CurrentObject),y   ;5 Get Object1's vertical co-ordinate
       sec                        ;2
       sbc    #$08                ;2 Adjust by 8 pixels for display
       sta    Obj1Y               ;3 ...And store for printing
       ldy    Object_State_LSB,x  ;4 Get low pointer to state value
       lda    Object_State_MSB,x  ;4 Get high pointer to state value
       beq    Animated_Object_1   ;2 If animated object then skip ahead
       sty    Obj1Lo              ;3 Otherwise, store for print...
       bne    Static_Object_1     ;2 ...And skip ahead to store the MSB (always branch)
Animated_Object_1:
       jsr    GetObjectState      ;6 Find current state in the state information
       iny                        ;2 Index to the state's corresponding graphic pointer
       lda    (CurrentObject),y   ;5 Get Object1's low graphic address
       sta    Obj1Lo              ;3 ...And store for printing
       iny                        ;2 Bump index
       lda    (CurrentObject),y   ;5 Get Object1's high graphic address
Static_Object_1:
       sta    Obj1Hi              ;3 ...And store for printing
  IF FLIP_DRAGONS
       jsr    CheckFlip           ;6
       sty    REFP0               ;3 ...And store reflect
  ENDIF
 
  IF UNROLL_POSITIONING = 0
       ldx    #$00                ;2 Reposition Object1...select sprite 1 (player0)
       lda    ObjX                ;3 ...And get current X co-ordinate
       jsr    PosSpriteX          ;6 Execute subroutine
  ENDIF
;do 2nd sprite...
       ldx    CurrentObject+3     ;3 Setup Object 2 to Print...get Object 2
       lda    Object_Data_LSB,x   ;4 Get low pointer to it's dynamic information
       sta    CurrentObject       ;3 ...And store
       lda    Object_Data_MSB,x   ;4 Get high pointer to it's dynamic information
       sta    CurrentObject+1     ;3 ...And store
       rol                        ;2 Move upper 3 bits to low position for sprite width
       rol                        ;2 .
       rol                        ;2 .
       rol                        ;2 .
       and    #$07                ;2 Trim to only those 3 bits
       ora    #$10                ;2 Value to include width of corresponding missile sprite
       sta    NUSIZ1              ;3 Update
       ldy    #$01                ;2 Set initial Y index
       lda    (CurrentObject),y   ;5 Get Object2's horizontal co-ordinate
       sta    ObjX                ;3 ...And store for printing
       iny                        ;2 Bump index
       lda    (CurrentObject),y   ;5 Get Object2's vertical co-ordinate
       sec                        ;2
       sbc    #$08                ;2 Adjust by 8 pixels for display
       sta    Obj2Y               ;3 ...And store for printing
       ldy    Object_State_LSB,x  ;4 Get low pointer to state value
       lda    Object_State_MSB,x  ;4 Get high pointer to state value
       beq    Animated_Object_2   ;2 If animated object then skip ahead
       sty    Obj2Lo              ;3 Otherwise, store for printing...
       bne    Static_Object_2     ;2 ...And skip ahead to store the MSB (always branch)
Animated_Object_2:
       jsr    GetObjectState      ;6 Find the current state in the state information
       iny                        ;2 Index to state's corresponding graphic pointer
       lda    (CurrentObject),y   ;5 Get Object2's low graphic address
       sta    Obj2Lo              ;3 ...And store
       iny                        ;2 Bump index
       lda    (CurrentObject),y   ;5 Get Object2's high graphic address
Static_Object_2:
       ldy    BatStateBackup      ;3 Restore bat's original state
       sty    BatR+4              ;3
 
       sta    Obj2Hi              ;3 ...And store
  IF FLIP_DRAGONS
       jsr    CheckFlip           ;6
       sty    REFP1               ;3 ...And store reflect
  ENDIF
 
  IF UNROLL_POSITIONING
       lda    ObjX                ;3 Get current X co-ordinate
       ldy    #$00                ;2 Start with 10 clock cycles (to avoid HBLANK)
       sec                        ;2
PosObject2:
       iny                        ;2 Divide the Coordinate wanted by fifteen
       sbc    #$0F                ;2 Get Course Horizontal Value...In Multiples of 5 Clock
       bcs    PosObject2          ;2 Cycles...(Therefore giving 15 Color Cycles)
       eor    #$FF                ;2 Flip remainder to positive value (inverted)
       sbc    #$06                ;2 Convert to left or right of current position
       asl                        ;2 Move to high nybble for TIA horizontal motion...
       asl                        ;2 .
       pha                        ;3
       ldx    #$00                ;2 Start with 10 clock cycles (to avoid HBLANK)
       lda    Temp                ;3 Get current horizontal co-ordinate of object1
       sec                        ;2
PosObject1:
       inx                        ;2 Divide the Coordinate wanted by fifteen
       sbc    #$0F                ;2 Get Course Horizontal Value...In Multiples of 5 Clock
       bcs    PosObject1          ;2 Cycles...(Therefore giving 15 Color Cycles)
       eor    #$FF                ;2 Flip remainder to positive value (inverted)
       sbc    #$06                ;2 Convert to left or right of current position
       sta    WSYNC               ;3 Wait for horizontal Blank
       asl                        ;2 Move to high nybble for TIA horizontal motion...
       asl                        ;2 .
       asl                        ;2 .
       asl                        ;2 .
PosCourse1:
       dex                        ;2 Count down the color cycles...
       bpl    PosCourse1          ;2 These are 5 machine/15 color cycles
       sta    HMP0                ;3 Set horizontal (fine) motion of sprite
       sta    RESP0               ;4 Reset the sprite, thus positioning it coursely
       sta    WSYNC               ;3 Wait for horizontal Blank
       pla                        ;4
       asl                        ;2 .
       asl                        ;2 .
PosCourse2:
       dey                        ;2 Count down the color cycles...
       bpl    PosCourse2          ;2 These are 5 machine/15 color cycles
       sta    HMP1                ;3 Set horizontal (fine) motion of sprite
       sta    RESP1               ;3 Reset the sprite, thus positioning it coursely
       rts                        ;6
  ELSE
       ldx    #$01                ;2 Reposition Object2...select sprite 2 (player1)
       lda    ObjX                ;3 ...And get current horizontal co-ordinate
;Fall into positioning subroutine (use it's RTS to return to main loop)
  ENDIF
PosSpriteX: ;Position Sprite X horizontally.
       ldy    #$02                ;2 Start with 10 clock cycles (to avoid HBLANK)
       sec                        ;2
PosSpriteX_1:
       iny                        ;2 Divide the Coordinate wanted by fifteen
       sbc    #$0F                ;2 Get Course Horizontal Value...In Multiples of 5 Clock
       bcs    PosSpriteX_1        ;2 Cycles...(Therefore giving 15 Color Cycles)
       eor    #$FF                ;2 Flip remainder to positive value (inverted)
       sbc    #$06                ;2 Convert to left or right of current position
       asl                        ;2 Move to high nybble for TIA horizontal motion...
       asl                        ;2 .
       asl                        ;2 .
       asl                        ;2 .
       sta    HMP0,x              ;4 Set horizontal (fine) motion of sprite
       sta    WSYNC               ;3 Wait for horizontal Blank
PosSpriteX_2:
       dey                        ;2 Count down the color cycles...
       bpl    PosSpriteX_2        ;2 These are 5 machine/15 color cycles
       sta    RESP0,x             ;4 Reset the sprite, thus positioning it coursely
       rts                        ;6
 
 
 
GetObjectState: ;Get pointer to current state
       lda    State_List_LSB,x    ;4 Get low pointer to state information
       sta    CurrentObject       ;3 ...And store
       lda    State_List_MSB,x    ;4 Get high pointer to state information
       sta    CurrentObject+1     ;3 ...And store
       lda.wy $00,y               ;4 Get current state value
       ldy    #$FD                ;2 Reset state table offset (INY's ahead bump this to zero)
GetObjectState_1:
       iny                        ;2 Goto next state in list of states (bump index by 3 bytes)
       iny                        ;2 .
       iny                        ;2 .
       cmp    (CurrentObject),y   ;5 Have we found it in the list of states?
       bcc    GetObjectState_2    ;2 If near, then state found (exit subroutine)
       bne    GetObjectState_1    ;2 Branch if state not found yet
GetObjectState_2:
       rts                        ;6
 
 
CheckInput: ;Check for input
       inc    LoCnt               ;5 Increment low count (3x frames)
       bne    GetJoystick         ;2 Branch if no rollover (12.8 seconds)
       lda    HiCnt               ;3 Increment hight count if needed
       clc                        ;2
       adc    #$04                ;2 Skip past low 2 bits
       bcc    No_HiCnt_Rollover   ;2
       ora    #$80                ;2 Keep high bit set on rollover
No_HiCnt_Rollover:
       sta    HiCnt               ;3 Update
GetJoystick:
       lda    SWCHA               ;4 Get joystick values
       cmp    #$FF                ;2 Check for any movement from either stick
       bne    GetJoystick_2       ;2 Branch if movement
       lda    SWCHB               ;4 Get the console switches
       and    #$03                ;2 Mask for the reset/select switches
       cmp    #$03                ;2 Have either of them been used?
       beq    GetJoystick_3       ;2 If not, branch
GetJoystick_2:
       lda    HiCnt               ;3
       and    #$03                ;2 Preserve low bits
       sta    HiCnt               ;3 Clear any attract mode
GetJoystick_3:
       rts                        ;6
 
 
 
CheckFlip:
  IF FLIP_DRAGONS
       ldy    #$00                ;2 Set default reflect
       cmp    #>GfxGDrag0         ;2 Check for chasing/biting dragons
       bne    Dont_Flip_Sprite    ;2 ...And skip ahead if not
    IF BW_PAUSE = 0
       lda    CurrentStick        ;3 Check CurrentStick...
       and    #$04                ;2 For BW switch status
       beq    Dont_Flip_Sprite    ;2 Skip flip if the BW switch is toggled
    ENDIF
       lda    PlayerX             ;3 Check against player's location
       sec                        ;2
       sbc    ObjX                ;3
       bmi    Dont_Flip_Sprite    ;2 If chasing from the right, don't bother
       ldy    #$08                ;2 Set reflect
Dont_Flip_Sprite:
  ENDIF
       rts                        ;6
 
 
ChangeColor: ;Change color of objects/screens...
       lsr                        ;2 Roll bit 0 to carry
       bcc    ChangeColor_2       ;2 If no carry, use original color value
       lda    LoCnt               ;3 Otherwise...use frame counter for color
ChangeColor_2:
       bit    HiCnt               ;3 Check for attract mode
       bpl    ChangeColor_3       ;2 Branch if clear
       eor    HiCnt               ;2 Otherwise, flip bits of attract with the original color
       and    #$FB                ;2 ...And strip bit 2
ChangeColor_3:
       asl                        ;2 Roll bits to their original position
       rts                        ;6
 
 
StartGame: ;Cold Start
       sei                        ;2 Set initial interrupt status
       cld                        ;2 Clear any powerup decimal mode
       ldy    #$00                ;2 Set Console = 2600 initially
       tya                        ;2 Pass zero value to A for ram clear loop ahead
       ldx    $D0                 ;3 Console type checking...look at a couple of ram locations
       cpx    #$2C                ;2 This value will be in a 7800
       bne    SaveConsole         ;2 Branch if not
       ldx    $D1                 ;3 First test passed...check another to be sure
       cpx    #$A9                ;2 This value will be in a 7800
       bne    SaveConsole         ;2 Branch if not
       iny                        ;2 Both tests pass...set Console = 7800 (Y=1)
SaveConsole:
       tax                        ;2 Clear X for ram clear loop
ResetAll:
       sta    $00,x               ;4 Save zeros to all ram
       txs                        ;2 ...And push stack status until it rolls
       inx                        ;2
       bne    ResetAll            ;2 Loop until done
       sty    Level               ;3 Save console type to low bit of the Level variable
       tya                        ;2 Move that bit a couple of spots upward
       asl                        ;2 .
       asl                        ;2 .
       sta    CurrentStick        ;3 ...And save to current "flip" status
       lda    #<(Rm14-Rm00)       ;2 Load a "dark" room number
       sta    SurroundR           ;3 ...And save it to the surround's room
  IF EDGE_PANELS
       lda    #$06                ;2 Position missiles. Near left boundry...
       ldx    #$02                ;2 Set index to point at missile0
       jsr    PosSpriteX          ;6 ...And position it
       lda    #$9D                ;2 Near right boundry...
  ELSE
       lda    #$0D                ;2 Position missiles. Near left boundry...
       ldx    #$02                ;2 Set index to point at missile0
       jsr    PosSpriteX          ;6  ...And position it
       lda    #$96                ;2 Near right boundry...
  ENDIF
       inx                        ;2 Bump index to point at missile1
       stx    LastObj             ;3 Bugfix...set last object to anything low
       stx    VDELBL              ;3 Set vertical delay of ball
       jsr    PosSpriteX          ;6  ...And position it
       sta    WSYNC               ;3 Wait for horizontal blank
       sta    HMOVE               ;3 Apply horizonal position
       bmi    SetupRoomObjects    ;2 Always branch- setup objects' initial rooms and positions
 
CheckGameStart: ;moved to main game loop to avoid triple-nesting
       lax    SWCHB               ;4 Get the console switches
       eor    #$FF                ;2 Flip (as reset active low)
       and    CurrentStick        ;3 Compare with what was before
       lsr                        ;2 And check only the reset switch
       bcc    CheckReset          ;2 If no reset then branch
       txa                        ;2
       lsr                        ;2 Check if switch still held
       bcs    KeepInactive        ;2 Branch if so
       lda    ChalliseR           ;3 Get the room the Challise is in
       cmp    #WinRoom            ;2 Is it in the yellow castle?
       beq    SetupRoomObjects    ;2 Branch if game already won (and set up a new game)
       lda    Control             ;3 Set the game to active
       and    #$7F                ;2 Signal that the game has started
       sta    Control             ;3
KeepInactive:
       lda    Control             ;3 Has the Game Started?
       bmi    SetupRoomObjects_1  ;2 If not then branch
  IF USE_TITLE_DISPLAY = 0
       jsr    DoVSYNC             ;6 Wait for VSYNC
  ENDIF
       ldx    #$07                ;2
Init_Loop:
       lda    Game_Start_Tbl-1,x  ;4 Reset the sound and player's room/X/Y to yellow castle
       sta    NoteCnt-1,x         ;4 .
       dex                        ;2
       bne    Init_Loop           ;2 Loop for all 7 bytes
       stx    RDragonR+4          ;3 Set the red dragon's state to OK
       stx    YDragonR+4          ;3 Set the yellow dragon's state to OK
       stx    GDragonR+4          ;3 Set the green dragon's state to OK
       sta    HiCnt               ;3 Set level select & map to be OFF
  IF RANDOM_XY
       jmp    SignalGameStart     ;3
  ELSE
       beq    SignalGameStart     ;2 Always branch
  ENDIF
 
StoreSwitchesJmp:
       jmp    StoreSwitches       ;3
 
CheckReset:
       lsr                        ;2 And check only the select switch
       bcc    StoreSwitchesJmp    ;2 Branch if select not being used
       lda    HiCnt               ;3 Check if level select shown (bit0)
       lsr                        ;2
       bcc    SetupRoomObjects    ;2 Branch if not (game in progress)
       lda    Level               ;3 Get current game level
       and    #$0F                ;2 Strip off any sound
       clc                        ;2
       adc    #$02                ;2 Increment the level number (by two)
       cmp    #$06                ;2 Have we reached the maximum?
       bcc    ResetSetup          ;2 Branch if not
       and    #$01                ;2 Otherwise, set back to zero
ResetSetup:
       sta    Level               ;3 Store the new level number
SetupRoomObjects:
       asl    Control             ;6 Set the game to inactive
       sec                        ;2
       ror    Control             ;6 ...By moving set carry flag into high bit
SetupRoomObjects_1:
  IF USE_TITLE_DISPLAY = 0
       ldy    #$00                ;2 Set the current room
       sty    PlayerRoom          ;3 ...To be the "Number" room
       sty    PrevRoom            ;3 And the previous room
       sty    PlayerY             ;3 And the current and previous vertical co-ordinate
       sty    PrevY               ;3 ...So the ball can't be seen
       iny                        ;2 Y = 1
  ELSE
       ldy    #$01                ;2 Set level select to be ON/map OFF
  ENDIF
       sty    HiCnt               ;3 Update
       lda    Level               ;3 Get the level number
       and    #$0F                ;2 Strip off any sound
       sta    Level               ;3
       and    #$0E                ;2 ...And the remaining bit before giving to the index
       tay                        ;2
       lda    Object_Map_Tbl,y    ;4 Get the low pointer to object locations
       sta    CurrentObject       ;3 ...And store
       lda    Object_Map_Tbl+1,y  ;4 Get the high pointer to object locations
       sta    CurrentObject+1     ;3 ...And store
  IF USE_TITLE_DISPLAY = 0
       jsr    DoVSYNC             ;6 Wait for VSYNC
  ENDIF
       ldy    #ByteNum            ;2 Copy all the objects dynamic information
SetupRoomObjects_2:
       lda    (CurrentObject),y   ;5 (The rooms and positions) into
       sta.wy MapPortR,y          ;4 ...The working area
       dey                        ;2
       bpl    SetupRoomObjects_2  ;2 Loop for all
       lda    Level               ;3 Get the level number
       and    #$0F                ;2 Strip off any sound
       cmp    #$04                ;2 Branch if level one
       bcc    SignalGameStart     ;2 Or two (Where all objects are in defined areas)
       ldy    #RndNum             ;2 Otherwise, randomize game objects...
  IF TEST_SEED
       lda    #SEED               ;2 Check against known setup pattern
       sta    LoCnt               ;3
  ENDIF
 
  IF RANDOM_XY
       lda    LoCnt               ;3
       lsr                        ;2
       sta    Delta1              ;3 Set initial "random" vertical location
  ENDIF
 
RandomizeLevel3_2:
       lda    LoCnt               ;3 Get the low input counter as seed
       lsr                        ;2
  IF RANDOM_XY
       sta    Temp                ;3 Use bits 6-0 to set a random horizontal location
  ENDIF
       lsr                        ;2
       lsr                        ;2 Generate a psudo-random room number
       lsr                        ;2
       lsr                        ;2
       sec                        ;2
       adc    LoCnt               ;3 Store the low input counter
       sta    LoCnt               ;3
       and    #RndMax             ;2 Trim so represents a room value
       cmp    Room_Bounds_Tbl+1,y ;4 If it is less than the lower bound for the object...
       bcc    RandomizeLevel3_2   ;2 ...Then get another
       cmp    Room_Bounds_Tbl+2,y ;4 If it equals or is less than the higher bound...
       beq    RandomizeLevel3_3   ;2 For the object...
       bcs    RandomizeLevel3_2   ;2 Then continue (branch if higher)
RandomizeLevel3_3:
       ldx    Room_Bounds_Tbl,y   ;4 Get the dynamic data index for this object
       sta    $00,x               ;4 Store the new room value
  IF RANDOM_XY
       eor    LoCnt               ;3 Set initial "random" vertical location
       lsr                        ;2
       eor    Delta1              ;3
       lsr                        ;2
       adc    #$18                ;2
       sta    $02,x               ;4 Store the new vertical location
       lda    Temp                ;3 Use bits 6-0 to set a random horizontal location
       sta    $01,x               ;4 Store the new horizontal location
  ENDIF
       dey                        ;2 Goto the next object
       dey                        ;2 .
       dey                        ;2 .
       bpl    RandomizeLevel3_2   ;2 Loop until all done
SignalGameStart:
  IF USE_TITLE_DISPLAY = 0
       jsr    PrintDisplay        ;6 Display rooms and objects
  ENDIF
SignalGameStart_2:
       lda    #NullNumber         ;2 Set no object carried (zero)
       sta    CarriedObj          ;3
StoreSwitches:
       lda    SWCHB               ;4 Load current switches
       and    #$0B                ;2 Keep B&W, Select, & Reset
       tax                        ;4 Load current switches
       eor    CurrentStick        ;3 Compare against last
       and    #$08                ;2 Keep only B&W
       beq    No_Toggle           ;2 Branch if no change
       lda    Level               ;3
       lsr                        ;2 Check for console type
       bcc    A2600               ;2 Branch if 2600
       txa                        ;2 Console is 7800...get switches
       and    #$08                ;2 Keep only B&W
       bne    No_Toggle           ;2 Skip return position
A2600:
       lda    CurrentStick        ;3
       eor    #$04                ;2 Flip status
       .byte $2C                  ;4 Skip 2 bytes
No_Toggle:
       lda    CurrentStick        ;3
       and    #$F4                ;2
       stx    CurrentStick        ;3
       ora    CurrentStick        ;3
       sta    CurrentStick        ;3
MainGameLoop:
       jsr    MakeSound           ;6 Make noise if necessary
  IF USE_TITLE_DISPLAY
       lda    HiCnt               ;3 Check if level select shown (bit0)
       lsr                        ;2
       bcc    MainGameLoop_1      ;2 Branch if level display/win screen is not shown
       jsr    DoVSYNC             ;6 Wait for VSYNC
       ldy    #TITLE_BANK         ;2
       jsr    TitleBankswitch     ;3
       jmp    CheckGameStart      ;3 Check for Game Start
MainGameLoop_1:
       lsr                        ;2
       bcc    No_Map_Display      ;2 Branch if player is not on map screen
       jsr    DoVSYNC             ;6 Wait for VSYNC
       lda    PlayerX             ;3 Position Ball Strite to the X Coordinate (all frames)
       clc                        ;2
       adc    #$12                ;2 Give a bit more of a margin for the small dot
       ldx    #$04                ;2 Select sprite #5 (ball)
       jsr    PosSpriteX          ;6 Execute repositioning subroutine
       ldy    #MAP_BANK           ;2
       jsr    MapBankswitch       ;3
       sta    CXCLR               ;3
       lda    Temp                ;3 Check if the map has been exited
       beq    NotReturningFromMap ;2 Branch if not
       lda    MapPortR+2          ;3 Load portal's Y co-ordinate
       sec                        ;2
       sbc    #$10                ;2 ...And adjust by a bit (so player doesn't hit it already)
       sta    MapPortR+2          ;3 Update
;do more map stuff here (such as scrambling enemy locations, etc)
 
 
 
NotReturningFromMap:
       jmp    CheckGameStart      ;3 Check for Game Start
No_Map_Display:
  ENDIF
 
 
 
 
 
       jsr    CheckInput          ;6 Check for controller input
  IF BW_PAUSE
       lda    CurrentStick        ;3
       and    #$04                ;2 Check B&W switch
       beq    NonActiveLoop       ;2 Branch if clear (pause)
  ENDIF
       lda    Control             ;3 Is the game active?
       bmi    NonActiveLoop       ;2 If not, Branch
       lda    ChalliseR           ;3 Get the room the chalise is in
       cmp    #WinRoom            ;2 Is it in the yellow castle?
       bne    MainGameLoop_2      ;2 If not, branch
       lda    Control             ;3
       ora    #$80                ;2
       sta    Control             ;3 Set the game to inactive
       lda    #$FF                ;2
       sta    NoteCnt             ;3 Set the note count to maximum
       lda    Sound               ;3
       and    #$0F                ;2 Set the noise type to end-noise
       sta    Sound               ;3 ...And store
MainGameLoop_2:
       ldy    #$00                ;2 Allow joystick read - all movement
       jsr    BallMovement        ;6 Check ball collisions and move ball
       jsr    MoveCarriedObject   ;6 Move any carried object
       jsr    DoVSYNC             ;6 Wait for VSYNC
       jsr    CacheObjects        ;6 Get next two objects to display
       jsr    PrintDisplay        ;6 Display the room and objects
       jsr    PickupPutdown       ;6 Deal with object pickup and putdown
       ldy    #$01                ;2 Disallow joystick read - move vertically only
       jsr    BallMovement        ;6 Check ball collisions and move ball
       jsr    Surround            ;6 Deal with surround moving
       jsr    DoVSYNC             ;6 Wait for VSYNC
       jsr    MoveBat             ;6 Move and deal with bat
       ldy    #Gates              ;2 For each portcullis
       jsr    Portals_2           ;6 Move and deal with portcullises
       jsr    PrintDisplay        ;6 Display the room and objects
       jsr    MoveGreenDragon     ;6 Move and deal with the green dragon
       jsr    MoveYellowDragon    ;6 Move and deal with the yellow dragon
       jsr    DoVSYNC             ;6 Wait for VSYNC
       ldy    #$02                ;2 Disallow stick read/bridge check - move horizontally only
       jsr    BallMovement        ;6 Check ball collisions and move ball
       jsr    MoveRedDragon       ;6 Move and deal with red dragon
       jsr    Magnet_Routine      ;6 Deal with the magnet
       jsr    PrintDisplay        ;6 Display the room and objects
       jmp    CheckGameStart      ;3 Check for Game Start
 
 
NonActiveLoop: ;Non-Active Game Loop
       jsr    DoVSYNC             ;6 Wait for VSYNC
  IF USE_TITLE_DISPLAY = 0
       lda    PlayerRoom          ;3
       bne    Dont_Slow_Display   ;2 Branch if level display is not shown
       jsr    PrintDisplay        ;6 Do another frame to slow down
       jsr    DoVSYNC             ;6
Dont_Slow_Display:
  ENDIF
       jsr    PrintDisplay        ;6 Display the room and objects
  IF SIMULATE_CHALISE_FLASH
       inc    BatR+4              ;5 Bump the bat state
  ENDIF
       jsr    CacheObjects        ;6 Get next two objects to display
       jmp    CheckGameStart      ;3 Check for Game Start
 
 
 
 
  IF UNROLL_SUBS = 0
FindObjHit: ;Find which object has hit object wanted
       bit    CXPPMM              ;3 Get Player00-Player01
       bpl    FindObjHit_2        ;2 If nothing, Branch
       cpx    CurrentObject+2     ;3 Is object 1 the one being hit?
       beq    FindObjHit_3        ;2 If so, Branch
       cpx    CurrentObject+3     ;3 Is object 2 the one being hit?
       beq    FindObjHit_4        ;2 If so, Branch
FindObjHit_2:
       lda    #NullNumber         ;2 Neither, select the null object (zero)
       rts                        ;6
FindObjHit_3:
       lda    CurrentObject+3     ;3 Yes, select the other
       rts                        ;6
FindObjHit_4:
       lda    CurrentObject+2     ;3 Yes, select the other
       rts                        ;6
  ENDIF
 
PickupPutdown: ;Deal with object pickup and putdown
       lda    INPT4               ;3 Get left joystick trigger
  IF MERGE_STICKS
       and    INPT5               ;3 Mix with right joystick trigger
  ENDIF
       bmi    PickupPutdown_2     ;2 Branch if no change
       lda    CarriedObj          ;3 Check carried object (if any)
       beq    PickupPutdown_2     ;2 Branch if nothing is being carried
       lda    #NullNumber         ;2 Set to nothing (zero)
       sta    CarriedObj          ;3 ...And drop object
       lda    Sound               ;2 Do the dropping noise:
       and    #$0F                ;2 Strip any current sound
       ora    #$50                ;2 Set noise type to five (drop object)
       sta    Sound               ;3
       lda    #$04                ;2
       sta    NoteCnt             ;3 Set noise count to four notes
PickupPutdown_2: ;Check for collision
       bit    CXP0FB              ;3 Get Ball-Player00 collision
       bvc    PickupPutdown_3     ;2 If nothing occured then branch
       ldx    CurrentObject+2     ;3 With Player00...get type of Player00
       jmp    CollisionDetected   ;3 Deal with collision
 
 
PickupPutdown_4:
    IF USE_TITLE_DISPLAY
       cpx    #MapPortNumber      ;2 Is the map portal hit?
       bne    PickupPutdown_5     ;2 Branch if not
       lda    HiCnt               ;3 Set the "map active" bit
       ora    #$02                ;2 .
       sta    HiCnt               ;3 .
       lda    #$40                ;2 Put player in the middle of the map
       sta    PlayerX             ;3 .
    ENDIF
PickupPutdown_5:
       rts                        ;6
 
 
 
PickupPutdown_3:
       bit    CXP1FB              ;3 Get Ball-Player01 collision
       bvc    PickupPutdown_5     ;2 If nothing has happened, branch
       ldx    CurrentObject+3     ;3 Get type of Player01...
CollisionDetected: ;Collision occurred (with something)...
       cpx    #SwordNumber        ;2 Is it carriable?
       bcc    PickupPutdown_4     ;2 If not, branch
       cpx    CarriedObj          ;3 Is it the object being carried?
       beq    PickupObject        ;2 If so, branch (and skip pickup sound)
       lda    Sound               ;3 Otherwise, set the object pickup noise
       and    #$0F                ;2 Strip any current sound
       ora    #$40                ;2 Set noise type to four (pickup object)
       sta    Sound               ;3
       lda    #$04                ;2 Set noise type to four notes
       sta    NoteCnt             ;3
PickupObject:
       stx    CarriedObj          ;3 Set the object as being carried
       lda    Object_Data_LSB,x   ;4 Get and store the low address
       tax                        ;2
       lda    CurrentStick        ;3 Direction moved into the object...
       lsr                        ;2
       lsr                        ;2
       lsr                        ;2
       lsr                        ;2
       tay                        ;2
       lda    $01,x               ;4 Get the object's X co-ordinate
       sec                        ;2
       sbc    PlayerX             ;3 Subtract the ball's X co-ordinate
       clc                        ;2
       adc    X6pixels,y          ;4
       sta    CarriedX            ;3 ...And store the difference for the carried object
       lda    $02,x               ;4 Get the object's Y coordinate
       sec                        ;2
       sbc    PlayerY             ;3 Subtract the Ball's Y coordinate
       clc                        ;2
       adc    Y6pixels,y          ;4
       sta    CarriedY            ;3 ...And store the difference for the carried object
MoveCarriedObject_2:
       rts                        ;6
MoveCarriedObject: ;Move the carried object
       ldy    CarriedObj          ;3 Get the object being carried
       beq    MoveCarriedObject_2 ;2 If nothing carried, return
       lda    Object_Data_LSB,y   ;4 Get and store the low address
       tax                        ;2 Transfer to the X register
       lda    PlayerRoom          ;3 Get the current room
       sta    $00,x               ;4 ...And store the object's current room
  IF ROTATING_SWORD
       cpy    #SwordNumber        ;2 Check if carried object is the sword
       bne    KeepOldCarryY       ;2 If not, skip this
       lda    CurrentStick        ;3 Get current direction moving
       lsr                        ;2 Move to low nybble...
       lsr                        ;2 .
       lsr                        ;2 .
       lsr                        ;2 .
       tay                        ;2 ...And give to an index register
       lda    CarryXtbl,y         ;4 Using a table, load the new position
       bmi    KeepOldCarryX       ;2 If invalid, don't update
       asl                        ;2
       sta    CarriedX            ;2 ...Or store as current
KeepOldCarryX:
       lda    CarryYtbl,y         ;4 Do the same for vertical
       bmi    KeepOldCarryY       ;2 If invalid, don't update
       asl                        ;2
       sta    CarriedY            ;3 ...Or store as current
KeepOldCarryY:
  ENDIF
       lda    PlayerX             ;3 Get the ball's horizontal co-ordinate
       clc                        ;2
       adc    CarriedX            ;3 Add the horizontal difference
       sta    $01,x               ;4 ...And store as the object's horizontal co-ordinate
       lda    PlayerY             ;3 Get the ball's vertical co-ordinate
       clc                        ;2
       adc    CarriedY            ;3 Add the vertical difference
       jmp    MoveObjectDelta     ;3 ...And jump to store
 
 
 
BallMovement: ;Check ball collisions and move ball using bit to check the two upper bits
       lda    CXBLPF              ;3 Get ball-playfield collision
  IF IGNORE_WALLS = 0
       bmi    PlayerCollision     ;2 Branch if collision (Player-Wall)
  ENDIF
       bit    CXM0FB              ;3 Get ball-missile00 collision
  IF IGNORE_LEFT_PANELS = 0
       bvs    PlayerCollision     ;2 Branch if collision. (Player-Left Thin)
  ENDIF
       bit    CXM1FB              ;3 Get ball-missile01 collision
       bvc    BallMovement_2      ;2 Branch if no collision
       lda    CurrentObject+3     ;3 If object2 (to print) is...
       cmp    #DotNumber          ;2 ...Not the black dot
  IF IGNORE_DOT = 0
       bne    PlayerCollision     ;2 ...Then collide with the panel
  ENDIF
BallMovement_2: ;using bit to check the flags instead of and...
       bit    CXP0FB              ;3 Get sprite0-ball collision
       bvc    BallMovement_3      ;2 If no collision then branch
       lda    CurrentObject+2     ;3 If object1 (to print) is "solid"...
       cmp    #LastPassNumber     ;2
       bcs    PlayerCollision     ;2 ...Then branch (collision)
BallMovement_3:
       bit    CXP1FB              ;3 Get sprite1-ball collision
       bvc    NoCollision         ;2 If no collision then branch
       lda    CurrentObject+3     ;3 If player01 to print is "passthru"...
       cmp    #LastPassNumber+1   ;2
       bcc    NoCollision         ;2 ...Then branch (no collision)
PlayerCollision: ;Player collided (with something)
       cpy    #$02                ;2 Are we checking for the bridge?
       bne    ReadStick           ;2 If not, branch
       lda    CarriedObj          ;3 Get the object being carried
       cmp    #BridgeNumber       ;2 Branch if it is the bridge
       beq    ReadStick           ;2
       lda    PlayerRoom          ;3 Get the current room
       cmp    BridgeR             ;3 Is the bridge in this room?
       bne    ReadStick           ;2 If not, branch
       lda    PlayerX             ;3 Check going thru bridge...get the ball's X coordinate
       sec                        ;2
       sbc    BridgeR+1           ;3 Subtract the bridge's X coordinate
       cmp    #$0A                ;2 If less than 10 pixels then forget it
       bcc    ReadStick           ;2
       cmp    #$17                ;2 If more than 23 pixels then forget it
       bcs    ReadStick           ;2
       lda    BridgeR+2           ;3 Get the bridge's Y coordinate
       sec                        ;2
       sbc    PlayerY             ;3 Subtract the ball's Y coordinate
       cmp    #$FC                ;2
       bcs    NoCollision         ;2 If more than $FC then going through bridge
       cmp    #$19                ;2 If more than $19 then forget it
       bcs    ReadStick           ;2
NoCollision: ;No collision (and going through bridge)
       lda    CurrentStick        ;3
       ora    #$F0                ;2 Reset the joystick input
       sta    CurrentStick        ;3
       lda    PlayerRoom          ;3 Get the current room...
       sta    PrevRoom            ;3 ...And store temporarily
       lda    PlayerX             ;3 Get the ball's X coordinate...
       sta    PrevX               ;3 ...And store temporarily
       lda    PlayerY             ;3 Get the ball's Y coordinate...
       sta    PrevY               ;3 ...And Store Temporarily
ReadStick: ;Read Sticks
       tya                        ;2 Check for zero (all movement)
       bne    ReadStick_2         ;2 If not, don't bother with joystick read
       lda    CurrentStick        ;3
       and    #$0F                ;2
       sta    CurrentStick        ;3
       lda    SWCHA               ;4 Read joysticks
  IF MERGE_STICKS
       asl                        ;2 Move right stick to upper nybble
       asl                        ;2 .
       asl                        ;2 .
       asl                        ;2 .
       and    SWCHA               ;4 ...And mix with left stick
  ELSE
       and    #$F0                ;2 Trim to read left stick only
  ENDIF
 
  IF ROTATING_SWORD
       cmp    #$F0                ;2
       beq    Not_the_sword       ;2 Not moving...skip update
       ldx    CarriedObj          ;3 Check object being carried
       cpx    #SwordNumber        ;2 Is it the sword?
       bne    Not_the_sword       ;2 If not, branch
       sta    SwordState          ;3 ...or update the sword's rotation based on movement
Not_the_sword:
  ENDIF
       ora    CurrentStick        ;3
       sta    CurrentStick        ;3
ReadStick_2:
       lda    PrevRoom            ;3 Get Temporary room...
       sta    PlayerRoom          ;3 ...And make it the current room
       lda    PrevX               ;3 Get temporary X coordinate...
       sta    PlayerX             ;3 ...And make it the ball's X coordinate
       lda    PrevY               ;3 Get temporary Y coordinate...
       sta    PlayerY             ;3 ...And make it the ball's Y coordinate
       lda    CurrentStick        ;3 Get the Joystick position
       ora    ReadStick_3,y       ;4 Merge out movement not allowed in this phase
       sta    ObjDir              ;3 ...And store cooked movement
       ldx    #PlayerRoom         ;2 Point to ball's co-ordinates
       ldy    #THREE_PIXELS       ;2 Set the delta for the ball (3 pixels)
       bne    MoveGroundObject    ;2 Branch to move the ball
 
 
  IF UNROLL_SUBS = 0
PBCollision: ;Get player-ball collision
       cmp    CurrentObject+2     ;3 Is it the first object?
       beq    PBCollision_2       ;2 YES - Then Branch
       cmp    CurrentObject+3     ;3 Is it the second object?
       beq    PBCollision_3       ;2 YES - Then Branch
       lda    #$00                ;2 Otherwise, nothing
       rts                        ;6
PBCollision_2:
       lda    CXP0FB              ;3 Get player00-ball collision
       .byte $2C                  ;4 Skip next 2 bytes (BIT.w)
PBCollision_3:
       lda    CXP1FB              ;3 Get player01-ball collision
       asl                        ;2 Move bit6 to bit7's spot
       rts                        ;6
  ENDIF
 
 
MoveGameObject:
       ldx    Delta1              ;3 Get dynamic data address
       lda    ObjDir              ;3 Get Movement
       bne    MoveGameObject_2    ;2 If movement then branch
       lda    $03,x               ;4 Use old movement
MoveGameObject_2:
       sta    $03,x               ;4 Store the new movement
       ldy    Delta2              ;3 Get the object's Delta
MoveGroundObject: ;Move the object
       and    #$F0                ;2 Check for motion
       beq    MoveObjectNoDelta   ;2 Skip if no movement
       cmp    #$F0                ;2
       beq    MoveObjectNoDelta   ;2 Skip if no movement
       sty    ObjAddress          ;3 Store delta
       cpy    #$00                ;2
       beq    MoveObjectNoDelta   ;2 Skip if no movement
       lsr                        ;2
       lsr                        ;2
       lsr                        ;2
       lsr                        ;2
       tay                        ;2
       lda    Xeor,y              ;4 Flip direction if applicable
       cmp    #$80                ;2
       beq    SkipXadjustment     ;2
       eor    ObjAddress          ;3 Load the delta
       clc                        ;2
       bpl    NotLeft             ;2
       adc    #$01                ;2
NotLeft:
       adc    $01,x               ;4 Add the horizontal coordinate
       sta    $01,x               ;4 Store the horizontal coordinate
SkipXadjustment:
       lda    Yeor,y              ;4 Flip direction if applicable
       cmp    #$80                ;2
       beq    MoveObjectNoDelta   ;2
       eor    ObjAddress          ;3 Load the delta
       clc                        ;2
       bpl    NotDown             ;2
       adc    #$01                ;2
NotDown:
       adc    $02,x               ;4 Add the vertical co-ordinate
MoveObjectDelta:
       sta    $02,x               ;4 Store the vertical co-ordinate
MoveObjectNoDelta:
       ldy    #Gates              ;2 Set to do the three portcullises
MoveGroundObject_2:
       sty    ObjAddress          ;3
       lda.wy YGateR,y            ;4 Get the portal state
       cmp    #$1C                ;2 Is it in a closed state?
       beq    GetPortal           ;2 If not, next portal
       ldy    ObjAddress          ;3 Deal with object moving out of a castle...get port number
       lda    $00,x               ;4 Get object's room number
       cmp    EntryRoomOffsets,y  ;4 Is it in a castle entry room
       bne    GetPortal           ;2 If not, next portal
       lda    $02,x               ;4 Get the object's Y coordinate
       cmp    #$0D                ;2 Is it above $0D i.e at the bottom?
       bpl    GetPortal           ;2 If so then branch
       lda    CastleRoomOffsets,y ;4 Get the castle room
       sta    $00,x               ;4 And put the object in the castle room
       lda    #$50                ;2
       sta    $01,x               ;4 Set the object's new X coordinate
       lda    #$2C                ;2
       sta    $02,x               ;4 Set the new object's Y coordinate
       lda    #$00                ;2
       sta.wy YGateR,y            ;4 Set the portcullis state to Open
       rts                        ;6
GetPortal:
       ldy    ObjAddress          ;3 Get the portcullis number
       dey                        ;2 ...Goto next portcullis
       bpl    MoveGroundObject_2  ;2 ...And loop until done
       ldy    $00,x               ;4 Check and Deal with Up...get the object's room
       lda    $02,x               ;4 Get the object's vertical co-ordinate
       cmp    #$6A                ;2 Has it reached above the top
       bmi    DealWithLeft        ;2 If not, branch
       lda    #$0D                ;2 Set new vertical co-ordinate to bottom
       sta    $02,x               ;4
       lda    North_Map_Tbl,y     ;4 Get the room number to the North
       jmp    GetNewRoom          ;3
DealWithLeft: ;Check and Deal with Left
       lda    $01,x               ;4 Get the object's horizontal co-ordinate
       cmp    #$02                ;2 Is it Two or less?
       bcc    DealWithLeft_2      ;2 If so, branch (off to left)
       cmp    #$F0                ;2 Is it's $F0 or more
       bcc    DealWithDown        ;2 If not, branch (off to left)
DealWithLeft_2:
       cpx    #PlayerRoom         ;2 Are we dealing with the ball?
       beq    DealWithLeft_3      ;2 If so then branch
       lda    #$9A                ;2 Set new horizontal co-ordinate for the others
       bne    DealWithLeft_4      ;2 Always branch
DealWithLeft_3:
       lda    #$9E                ;2 Set new horizontal co-ordinate for the ball
DealWithLeft_4:
       sta    $01,x               ;4 Store the next horizontal co-ordinate
       lda    West_Map_Tbl,y      ;4 Get the room number to the Left
       jmp    GetNewRoom          ;3
DealWithDown: ;Check and Deal with Down
       lda    $02,x               ;4 Get object's Y coordinate
       cmp    #$0D                ;2 If it's greater than $0D
       bcs    DealWithRight       ;2 ...Then branch
       lda    #$69                ;2 Set new vertical co-ordinate
       sta    $02,x               ;4
       lda    South_Map_Tbl,y     ;4 Get the room number to the South
       jmp    GetNewRoom          ;3
DealWithRight: ;Check and Deal with Right
       lda    $01,x               ;4 Get the object's horizontal co-ordinate
       cpx    #PlayerRoom         ;2 Are we dealing with the ball?
       bne    DealWithRight_2     ;2 Branch if not
       cmp    #$9F                ;2 Has the object reached the right?
       bcc    MovementReturn      ;2 Branch if not
       lda    $00,x               ;4 Get the Ball's Room
       cmp    #<(Rm03-Rm00)       ;2 Is it room #3 (Right to secret room)
       bne    DealWithRight_3     ;2 Branch if not
  IF IGNORE_DOT = 0
       lda    DotR                ;3 Check the room of the black dot
       cmp    #<(Rm15-Rm00)       ;2 Is it in the hidden room area?
       beq    DealWithRight_3     ;2 If so, Branch
  ENDIF
       lda    #$02                ;2 Set the horizontal co-ordinate
       sta    $01,x               ;4
       lda    #<(Rm1E-Rm00)       ;2 Manually change to secret room
       bne    AdjustRoomLevel_2   ;2 Always branch (store room # as current and exit)
DealWithRight_2:
       cmp    #$9B                ;2 Has the object reached the right of screen?
       bcc    MovementReturn      ;2 Branch if not (no room change)
DealWithRight_3:
       lda    #$02                ;2 Set the next horizontal co-ordinate
       sta    $01,x               ;4
       lda    East_Map_Tbl,y      ;4 Get the room number to the Right
GetNewRoom: ;Adjust room for different levels
       bpl    AdjustRoomLevel_2   ;2 Branch if high bit not set
       and    #$7F                ;2 Remove the high bit...
       tay                        ;2 Set pointer
       lda    Level               ;3 Get the level number
       and    #$0E                ;2 Strip off any sound
       cmp    #$02                ;2 Level 2?
       beq    FindLevel2Room      ;2 Branch if second game
       cmp    #$04                ;2 Level 3?
       beq    FindLevel3Room      ;2 Branch if second game
       lda    Level1Diffs,y       ;4 Use as an offset to get the next room
AdjustRoomLevel_2:
       sta    $00,x               ;4 ...And store as new object's room
MovementReturn:
       rts                        ;6
 
FindLevel2Room:
       lda    Level2Diffs,y       ;4 Use as an offset to get the next room
       sta    $00,x               ;4 ...And store as new object's room
       rts                        ;6
 
FindLevel3Room:
       lda    Level3Diffs,y       ;4 Use as an offset to get the next room
       sta    $00,x               ;4 ...And store as new object's room
       rts                        ;6
 
 
 
GetLikedObject: ;Find liked object and get movement
       ldy    #$FF                ;2 Set index to zero
GetLikedObject_2:
       iny                        ;2
       sty    Index1              ;3 Set the index number
       lda    (ObjLst),y          ;5 Get first object
       beq    GetLikedObject_3    ;2 Check for table end right away
       sta    Temp                ;3
       tax                        ;2
       lda    $00,x               ;4 Get object1's room
       sta    ObjDir              ;3 Temp (xroom)
       iny                        ;2
       lda    (ObjLst),y          ;5 Get second object
       tax                        ;2
       lda    $00,x               ;4 Compare with object2's room
       cmp    ObjDir              ;3 Temp (xroom)
       bne    GetLikedObject_2    ;2 If not the same room then branch
       cpx    ObjCr               ;3 Have we matched the second object
       beq    GetLikedObject_2    ;2 ...For difficulty? (if so, carry on)
       lda    Temp                ;3 Temp (x)
       cmp    ObjCr               ;3 Have we matched the first object?
       beq    GetLikedObject_2    ;2 Branch if so (56 cycles each pass)
GetLikedObject_4: ;Work out object's movement
       ldy    Temp                ;3 Temp (x)
       lda    #$FF                ;2 Set object movement to none
       sta    ObjDir              ;3
       lda    $00,x               ;4 Get object2's room
       cmp.wy $00,y               ;4 Compare it with object's room
       bne    GetLikedObject_8    ;2 If not the same, forget it
       lda    $01,x               ;4 Get Object2's horizontal co-ordinate
       cmp.wy $01,y               ;4 Get Object1's horizontal co-ordinate
       bcc    GetLikedObject_5    ;2 If Object2 to left of Object1 then branch
       beq    GetLikedObject_6    ;2 If Object2 = Object1 then branch
       lda    #$7F                ;2 Signal a move right
       bne    GetLikedObject_5b   ;2 Always branch
GetLikedObject_5:
       lda    #$BF                ;2 Signal a move left
GetLikedObject_5b:
       cpy    #MagnetR            ;2 Bugfix...
       bne    GetLikedObject_5c   ;2
       eor    #$C0                ;2
GetLikedObject_5c:
       sta    ObjDir              ;3
GetLikedObject_6:
       lda    $02,x               ;4 Get Object2's vertical co-ordinate
       cmp.wy $02,y               ;4 Compare with Get Object1's vertical co-ordinate
       bcc    GetLikedObject_7    ;2 If Object2 is below Object1 then branch
       beq    GetLikedObject_8    ;2 If Object2 is equal to Object1's position then branch
       lda    #$EF                ;2 Signal a move up
       bne    GetLikedObject_9    ;2 Always branch
GetLikedObject_8:
       lda    ObjDir              ;3 Get the move
       rts                        ;6
GetLikedObject_7:
       lda    #$DF                ;2 Signal a move down
GetLikedObject_9:
       and    ObjDir              ;3 Get object movement
       cpy    #MagnetR            ;2 Bugfix...
       bne    GetLikedObject_3    ;2
       ldy    MagSave             ;3 Bugfix...check backup
       cpy    #<MAGNET_HEIGHT     ;2 ...For lowest valid position
       bcc    GetLikedObject_3    ;2 Branch if clear (and continue current course)
       eor    #$30                ;2 ...Otherwise, reverse direction
GetLikedObject_3: ;tag moved down here
       sta    ObjDir              ;3
       rts                        ;6
 
 
MoveRedDragon: ;Move the Red Dragon
       lda    #<RedDragMatrix     ;2 Select red dragon's "liked" matrix address LSB
       ldy    #THREE_PIXELS       ;2 Use fast speed for the red dragon (delta)
       ldx    #RDragonNumber      ;2 ...And point at the first byte of ram for the dragon
       bne    MoveDragon          ;2 Always branch
MoveYellowDragon: ;Move the Yellow Dragon
       lda    #<YelDragMatrix     ;2 Select yellow dragon's "liked" matrix address LSB
       ldx    #YDragonNumber      ;2 ...And point at the first byte of ram for the dragon
       bne    DragonSlowSpeed     ;2 Always branch
MoveGreenDragon: ;Move the Green Dragon
       lda    #<GreenDragonMatrix ;2 Select green dragon's "liked" matrix address LSB
       ldx    #GDragonNumber      ;2 ...And point at the first byte of ram for the dragon
DragonSlowSpeed:
       ldy    #TWO_PIXELS         ;2 Slow speed (delta)
;existing lines...
MoveDragon:
       sta    ObjLst              ;3 Set low address of object store
       sty    Delta2              ;3 Set the dragon's delta
       lda    #>RedDragMatrix     ;2 NOTE: all dragon matrixes must be on the same page!
       sta    ObjLst+1            ;3 Set high address of object store
       stx    ObjectNumber        ;3 Save Object were dealing with
       lda    Object_Data_LSB,x   ;4 Get the Object's dynamic data
       tax                        ;2
       lda    $04,x               ;4 Get the Object's state
  IF ANIMATE_DRAGON
       lsr                        ;2 Ignore any animation frame
  ENDIF
       beq    MoveDragon_1        ;2 Branch if roaming
MoveDragon_6:
;these values still work...since the state was LSR'ed before going here
       cmp    #$01                ;2 Is it in state 02 (dead)?
       beq    MoveDragon_9        ;2 Branch if so (return)
       cmp    #$02                ;2 Is it in state 04 (ball already swallowed)?
       bne    MoveDragon_7        ;2 Branch if not
       lda    $01,x               ;4 Get the dragon's horizontal co-ordinate
       clc                        ;2 Normal dragon state 2 (eaten ball)
       adc    #$03                ;2 Adjust to it's belly location
       sta    PlayerX             ;3 ...And store as the ball's horizontal co-ordinate
       sta    PrevX               ;3 ...And ball's previous horizontal co-ordinate
       lda    $02,x               ;4 Get the Dragon's vertical co-ordinate
       sec                        ;2
       sbc    #$0B                ;2 Adjust to it's belly location
       sta    PlayerY             ;3 ...And store as the ball's vertical co-ordinate
       sta    PrevY               ;3 ...And ball's previous vertical co-ordinate
       ldy    $00,x               ;4 Get the dragon's current room
       sty    PlayerRoom          ;3 Store as the ball's current room
       sty    PrevRoom            ;3 ...And previous room
       rts                        ;6
MoveDragon_7: ;Dragon Roaring
  IF ANIMATE_DRAGON
       lda    $04,x               ;4 Get the Object's state
  ENDIF
       tay                        ;2 Transfer state to Y
       iny                        ;2 Bump state
       sty    $04,x               ;4 Save it's state
       cpy    #$FC                ;2 Is it near the end?
       bcc    MoveDragon_9        ;2 If not, branch
       lda    ObjectNumber        ;3 Get the dragon's number
 
  IF UNROLL_SUBS
;Get player-ball collision
       cmp    CurrentObject+2     ;3 Is it the first object?
       beq    DragCollision_2     ;2 YES - Then Branch
       cmp    CurrentObject+3     ;3 Is it the second object?
       bne    MoveDragon_9        ;2 NO - Then Branch
       lda    CXP1FB              ;3 Get player01-ball collision
       .byte $2C                  ;4 Skip next 2 bytes (BIT.w)
DragCollision_2:
       lda    CXP0FB              ;3 Get player00-ball collision
       asl                        ;2 Move bit6 to bit7's spot
  ELSE
       jsr    PBCollision         ;6 Get the player-ball collision
  ENDIF
 
       bpl    MoveDragon_9        ;2 If not, branch
  IF ANIMATE_DRAGON
       lda    #$04                ;2 Set the state to state 04 : eaten
  ELSE
       lda    #$02                ;2 Set the state to state 02 : eaten
  ENDIF
       sta    $04,x               ;4
       lda    Sound               ;3
       and    #$0F                ;2 Strip any current sound
       ora    #$20                ;2 Set noise two (roar)
       sta    Sound               ;3
       lda    #$10                ;2 Set the count of noise to 17 frames
       sta    NoteCnt             ;3
       lda    #$9B                ;2 Get the maximum horizontal co-ordinate
       cmp    $01,x               ;4 Compare with the dragon's horizontal co-ordinate
       beq    MoveDragon_8        ;2
       bcs    MoveDragon_8        ;2
       sta    $01,x               ;4 If too large then use it
MoveDragon_8:
       lda    #$0F                ;2 Set minimum vertical co-ordinate
       cmp    $02,x               ;4 Compare with the dragon's vertical co-ordinate
       bcc    MoveDragon_9        ;2
       sta    $02,x               ;4 If too small, set as dragon's vertical co-ordinate
MoveDragon_9:
       rts                        ;6
 
 
 
 
MoveDragon_1:
  IF ANIMATE_DRAGON
       sta    $04,x               ;5 Save w/bit0 missing
       lda    BatR+4              ;3 Get bat's animation
       lsr                        ;2 Use only 1 bit...roll bit2 down to carry
       lsr                        ;2 .
       lsr                        ;2 .
       rol    $04,x               ;6 ...And merge carry into dragon's state as bit0
       lda    #$00                ;2 Reload zero value needed ahead
  ENDIF
       bit    SWCHB               ;4 Dragon normal (State 1)...read console switches
       bmi    MoveDragon_2        ;2 If expert, branch (don't ignore sword)
       lda    #SwordR             ;2 Set easy - ignore sword
MoveDragon_2:
       sta    ObjCr               ;3 Store difficulty
       stx    Delta1              ;3 Store dynamic data address
       jsr    GetLikedObject      ;6 Get liked object and movement
       jsr    MoveGameObject      ;6
       lda    ObjectNumber        ;3 Get Object#
 
  IF UNROLL_SUBS
;Get player-ball collision
       cmp    CurrentObject+2     ;3 Is it the first object?
       beq    DragCollision_3     ;2 YES - Then Branch
       cmp    CurrentObject+3     ;3 Is it the second object?
       bne    MoveDragon_4        ;2 NO - Then Branch
       lda    CXP1FB              ;3 Get player01-ball collision
       .byte $2C                  ;4 Skip next 2 bytes (BIT.w)
DragCollision_3:
       lda    CXP0FB              ;3 Get player00-ball collision
       asl                        ;2 Move bit6 to bit7's spot
  ELSE
       jsr    PBCollision         ;6 Get the player-ball collision
  ENDIF
 
       bpl    MoveDragon_4        ;2 If none then branch
       lda    Level               ;3 Get level number
       and    #$0E                ;2 Strip off any sound
       tay                        ;2 Create lookup
       bit    SWCHB               ;4 Get console switches
       bvc    MoveDragon_3        ;2 If P0="B" then branch
       iny                        ;2 Bump lookup
MoveDragon_3:
       lda    DragonDiff,y        ;4 Get new state
       sta    $04,x               ;4 Store as dragon's state (open mouthed)
       lda    PrevX               ;3 Get temp ball horizontal co-ordinate
       sta    $01,x               ;4 ...And store as dragon's
       lda    PrevY               ;3 Get temp ball vertical co-ordinate
       sta    $02,x               ;4 ...And store as dragon's
       lda    #$10                ;2
       sta    NoteCnt             ;3 Set noise count to 17 frames
       ora    Sound               ;3
       and    #$1F                ;2 Strip any current sound and mix w/bit4 set
       sta    Sound               ;3 Set noise type to 01 (roar)
MoveDragon_4:
       stx    ObjAddress          ;3 Store object's dynamic data address
       ldx    ObjectNumber        ;3 Get the object number
 
  IF UNROLL_SUBS
FindDragHit: ;Find which object has hit object wanted
       bit    CXPPMM              ;3 Get Player00-Player01
       bpl    FindDragHit_2       ;2 If nothing, Branch
       lda    CurrentObject+3     ;3 Select object2
       cpx    CurrentObject+2     ;3 Is object1 the one being hit?
       beq    FindDragHit_4       ;2 If so, Branch
       cpx    CurrentObject+3     ;3 Is object2 the one being hit?
       beq    FindDragHit_3       ;2 If so, Branch
FindDragHit_2:
       lda    #NullNumber         ;2 Neither, select the null object (zero)
       beq    FindDragHit_4       ;2 Always branch
FindDragHit_3:
       lda    CurrentObject+2     ;3 If object2 hit, select object1
FindDragHit_4:
  ELSE
       jsr    FindObjHit          ;6 See if another object has hit the dragon
  ENDIF
 
       ldx    ObjAddress          ;3 Get the object's address
       cmp    #SwordNumber        ;2 Has the sword hit the dragon?
       bne    MoveDragon_5        ;2 If not, branch
  IF ANIMATE_DRAGON
       lda    #$02                ;2 Set the state to 02 (dead)
  ELSE
       lda    #$01                ;2 Set the state to 01 (dead)
  ENDIF
       sta    $04,x               ;4
       lda    Sound               ;3
       and    #$0F                ;2 Strip any current sound
       ora    #$30                ;2 Set sound three (dying dragon)
       sta    Sound               ;3 ...And store
       lda    #$10                ;2 Set a noise count of 17 frames
       sta    NoteCnt             ;3 ...And store
MoveDragon_5:
       rts                        ;6
 
 
MoveBat: ;Move and deal with the bat
       ldx    #BatR               ;2 Set the bat's dynamic data address
       ldy    #THREE_PIXELS       ;2 Set the bat's delta (3 pixels)
       inc    BatR+4              ;5 Bump the bat state
       lda    BatR+4              ;3 Get the bat state
       cmp    #$10                ;2 In the "fed-up" range?
       beq    MoveBat_2           ;2 Bat is STILL fed-up...correct the state
       bcc    MoveBat_3           ;2 If bat is fed-up then branch
       lda    BatR+3              ;3 Get the bat's movement
       jsr    MoveGroundObject    ;6 Move the bat
       jmp    MoveBat_4           ;3 Jump to update the bat's carried object (if any)
MoveBat_2: ;Bat Fed-Up, correct the state
       lda    #$00                ;2 Bump state back to zero
       sta    BatR+4              ;3
MoveBat_3: ;Bat Fed-Up
       stx    Delta1              ;3 Store the bat's dynamic data address
       sty    Delta2              ;3 Store the bat's delta (3 pixels)
       lda    #<BatMatrix         ;2 Set the low address of object store
       sta    ObjLst              ;3
       lda    #>BatMatrix         ;2 Set the high address of object store
       sta    ObjLst+1            ;3
       lda    BatR+5              ;3 Get object being carried by bat...
       sta    ObjCr               ;3 ...And copy
       jsr    GetLikedObject      ;6 Get liked object and movement
       jsr    MoveGameObject      ;6 Move the bat
       ldy    Index1              ;3 Get "object liked" index
       lda    (ObjLst),y          ;5 Look up the object in the bat's table of "liked" objects
       beq    MoveBat_4           ;2 If nothing found then forget it
       iny                        ;2
       lax    (ObjLst),y          ;5 Get the object wanted
       lda    $01,x               ;4 Get the object's horizontal co-ordinate
       sec                        ;2 ;See if the bat can pick up object
       sbc    BatR+1              ;3 Find the difference with the bat's horizontal co-ordinate
       clc                        ;2
       adc    #$04                ;2 Adjust so the bat is in middle of the object
       and    #$F8                ;2 Is the bat within seven pixels either direction?
       bne    MoveBat_4           ;2 If not, no pickup possible
       lda    $02,x               ;4 Get the object's vertical co-ordinate
       sec                        ;2
       sbc    BatR+2              ;3 Find the difference with the bat's vertical co-ordinate
       clc                        ;2
       adc    #$04                ;2 Adjust
       and    #$F8                ;2 Is the bat within seven pixels either direction?
       bne    MoveBat_4           ;2 If not, no pickup possible
       stx    BatR+5              ;3 Both passed...store the object as being carried
  IF BAT_REVIVES_DRAGONS
       cpx    #GDragonR+1         ;2 Compare to whatever the last dragon is
       bcs    MoveOn              ;2 Branch if object is not a dragon
       sta    $04,x               ;4 Otherwise, use known A value to revive applicable dragon
MoveOn:
  ENDIF
       lda    BatR+4              ;3
       ora    #$10                ;2 Reset the bat's "fed-up" time
       sta    BatR+4              ;3
MoveBat_4: ;Move object being carried by bat
       ldx    BatR+5              ;3 Get object being carried by bat
       beq    MoveBat_5           ;2 Branch if none
       lda    BatR                ;3 Get the bat's room
       sta    $00,x               ;4 Store this as the carried object's room
       lda    BatR+1              ;3 Get the bat's horizontal co-ordinate
       clc                        ;2
       adc    #$08                ;2 Adjust to the right by 8 pixels
       sta    $01,x               ;4 Make it the object's horizontal co-ordinate
       lda    BatR+2              ;3 Get the bat's vertical co-ordinate
       sta    $02,x               ;4 Store it as the object's vertical co-ordinate
       lda    BatR+5              ;3 Get the object being carried by the bat
       ldy    CarriedObj          ;3 Get the object being carried by the ball
       eor    Object_Data_LSB,y   ;4 Are the the same?
       bne    MoveBat_5           ;2 If not, branch
       sta    CarriedObj          ;3 Otherwise, store null object to player (bat wins)
MoveBat_5:
       rts                        ;6
 
 
 
Portals_2: ;Deal with Portcullis and Collisions
       ldx    PortOffsets,y       ;4 Get the portcullises offset number
 
  IF UNROLL_SUBS
FindGateHit: ;Find which object has hit object wanted
       bit    CXPPMM              ;3 Get Player00-Player01
       bpl    FindGateHit_2       ;2 If nothing, Branch
       lda    CurrentObject+3     ;3 Select object2
       cpx    CurrentObject+2     ;3 Is object1 the one being hit?
       beq    FindGateHit_4       ;2 If so, Branch
       cpx    CurrentObject+3     ;3 Is object2 the one being hit?
       beq    FindGateHit_3       ;2 If so, Branch
FindGateHit_2:
       lda    #NullNumber         ;2 Neither, select the null object (zero)
       beq    FindGateHit_4       ;2 Always branch
FindGateHit_3:
       lda    CurrentObject+2     ;3 If object2 hit, select object1
FindGateHit_4:
  ELSE
       jsr    FindObjHit          ;6 See if an object collided with it
  ENDIF
 
       sta    Temp                ;3 ...Store that object
       ldx    YGateR,y            ;4
       cmp    KeyOffsets,y        ;4 Is it the associated key?
  IF NO_TRAP
       beq    Portals_7a          ;2 If so, then branch
  ELSE
       bne    Portals_3           ;2 If not, then branch
       inx                        ;2 Otherwise, change the portcullis state to open or close
  ENDIF
Portals_3:
       cpx    #$1C                ;2 Is it closed?
       beq    Portals_8           ;2 If so, then branch (altered)
       lda    PortOffsets,y       ;4 Get the portcullis number
 
  IF UNROLL_SUBS
;Get player-ball collision
       cmp    CurrentObject+2     ;3 Is it the first object?
       beq    GateCollision_2     ;2 YES - Then Branch
       cmp    CurrentObject+3     ;3 Is it the second object?
       bne    Portals_4           ;2 NO - Then Branch
       lda    CXP1FB              ;3 Get player01-ball collision
       .byte $2C                  ;4 Skip next 2 bytes (BIT.w)
GateCollision_2:
       lda    CXP0FB              ;3 Get player00-ball collision
GateCollision_3:
       asl                        ;2 Move bit6 to bit7's spot
  ELSE
       jsr    PBCollision         ;6 Get the player-ball collision
  ENDIF
 
       bpl    Portals_4           ;2 If none, then branch
       lda    #$00                ;2 Set the portcullis to open state
       sta    ObjAddress          ;3 Store port's state temporarily (altered)
       ldx    #PlayerRoom         ;2 Set to the castle
       bne    Portals_6           ;2 Always branch (put the ball in the castle) (altered)
 
Portals_4:
       stx    ObjAddress          ;3 Store port's state temporarily (altered)
       ldx    Temp                ;3 Get object
       cpx    #LastPassNumber     ;2 Is it a passthru object?
       bcc    Portals_7           ;2 If so, branch
       lda    Object_Data_LSB,x   ;4 Get the object's ram address
       tax                        ;2 Transfer the object's ram address to X
Portals_6:
       lda    EntryRoomOffsets,y  ;4 Look up the castle entry room for this portal
       sta    $00,x               ;4 Make it the object's room
       lda    #$10                ;2 Give the object a new vertical co-ordinate
       sta    $02,x               ;4
Portals_7:
       ldx    ObjAddress          ;3 Retrieve port's state (altered)
       beq    Portals_8           ;2 If open, then branch (altered)
Portals_7a:
       inx                        ;2
       cpx    #$38                ;2 Has it reached the maximum state?
       bne    Portals_8           ;2 If not, branch
       ldx    #$00                ;2 Set to open state
Portals_8:
       stx    YGateR,y            ;4
       dey                        ;2 Goto the next portcullis
       bpl    Portals_2           ;2 Loop until done
       rts                        ;6
 
 
 
Magnet_Routine: ;Deal with magnet
       lda    MagnetR+2           ;3 Get Magnet's vertical co-ordinate
       sta    MagSave             ;3 Make a backup for when exiting this routine
       sec                        ;2
       sbc    #<MAGNET_HEIGHT     ;2 Adjust to it's "poles" during it
       sta    MagnetR+2           ;3
       lda    #$00                ;2 Ignore difficulty
       sta    ObjCr               ;3
       lda    #<MagnetMatrix      ;2 Set low address of object store
       sta    ObjLst              ;3
       lda    #>MagnetMatrix      ;2 Set high address of object store
       sta    ObjLst+1            ;3
       jsr    GetLikedObject      ;6 Get "liked object" and set movement
       lda    ObjDir              ;3 Get movement
       beq    Mag_2               ;2 If none, then forget It
       ldy    #ONE_PIXEL          ;2 Set delta to 1 pixel (very slow movement)
       jsr    MoveGroundObject    ;6 Move the "liked" object until it's equal to magnet's poles
Mag_2:
       lda    MagSave             ;3 Restore magnet's actual position
       sta    MagnetR+2           ;3
       rts                        ;6
 
 
 
Surround: ;Deal with surround movement
       ldy    PlayerRoom          ;3 Get the current room
       lda    RoomGFX_MSB_Tbl,y   ;4 Get the room's CTRL
       and    #SURROUND           ;2 Is it "dark"?
       beq    Surround_4          ;2 If not, branch
       sty    SurroundR           ;3 Store room as the surround's room
       lda    PlayerX             ;3 Get the ball's horizontal co-ordinate
       sec                        ;2
       sbc    #$10                ;2 Adjust surround sprite to 16 pixels left
       bpl    Surround_3          ;2 (00 to 7F OK)
       cmp    #$F0                ;2 Is it close to the right edge?
       bcc    Surround_2          ;2 Branch if not
       lda    #$01                ;2 Flick surround to the left
       bne    Surround_3          ;2 Always branch
Surround_2:
       lda    #$7F                ;2 If higher than $7F, keep boundry on the right
Surround_3:
       sta    SurroundR+1         ;3 ...And store as surround's horizontal co-ordinate
       lda    PlayerY             ;3 Get the ball's vertical co-ordinate
       clc                        ;2
       adc    #$0E                ;2 Adjust surround sprite to 14 pixels up
       sta    SurroundR+2         ;3 ...And store as surround's vertical co-ordinate
Surround_4:
       rts                        ;6
 
 
 
MakeSound: ;Make a noise
       lda    Sound               ;3 Get the noise type in upper nybble
       lsr                        ;2 Move down to lower nybble...
       lsr                        ;2 .
       lsr                        ;2 .
       lsr                        ;2 .
       tax                        ;2 ...And pass to X for index
       ldy    NoteCnt             ;3 Check current note count
       beq    NoiseSaveVolume     ;2 Branch if no noise to be made
MakeSound_2:
       dey                        ;2
       sty    NoteCnt             ;3 Goto the next note
       tya                        ;2
       ldy    #$00                ;2
       dex                        ;2 Game over noise?
       bmi    NoiseGameOver       ;2 Branch if so
       dex                        ;2 Roar noise?
       bmi    NoiseRoar           ;2 Branch if so
       dex                        ;2 Eaten player noise?
       bmi    EatenNoise          ;2 Branch if so
       dex                        ;2 Dying dragon noise?
       bmi    DragDieNoise        ;2 Branch if so
       dex                        ;2 Picking up object noise?
       bmi    NoiseGetObject      ;2 Branch if so
       dex                        ;2 Dropping object noise?
       bpl    NoiseSaveVolume     ;2 Branch if not
;Sounds...Set A (Frequency), Y (Volume), and X (distortion)...& branch to NoiseSave
;Noise 5 : Dropping Object
       eor    #$03                ;2 Reverse it as pitch goes up
NoiseGetObject: ;Noise 4 : Picking up an Object
       ldy    #$05                ;2
       bne    NoiseSaveX          ;2 Always branch
NoiseGameOver: ;Noise 0 : winning game
  IF FLASH_WALLS
       sta    COLUPF              ;3 Color flash playfield
  ENDIF
  IF FLASH_GROUND
       sta    COLUBK              ;3 Color flash background
  ENDIF
       tax                        ;2 Audio-Control 0
       lsr                        ;2
       tay                        ;2 Audio-Volume 0
       lsr                        ;2
       lsr                        ;2
       bpl    NoiseSave           ;2 Always branch
NoiseRoar: ;Noise 1 : Roar
       tay                        ;2 Put the note count in the volume
       lsr                        ;2
       ldx    #$03                ;2 If it was even...
       bcs    SetVolume           ;2 ...Then branch
       ldx    #$08                ;2 Get a different audio distortion value
SetVolume:
       tya                        ;2 Set the volume
       clc                        ;2
       adc    #$70                ;2 Set the frequency
NoiseFrequency:
       lsr                        ;2 Divide by four
       lsr                        ;2 .
       bpl    NoiseSave           ;2 Always branch
DragDieNoise: ;Noise 3 : Dying Dragon
       tay                        ;2 Put the note count in the volume
       eor    #$1F                ;2
       ldx    #$04                ;2 Set the audio distortion
       bne    NoiseSave           ;2 Always branch
EatenNoise: ;Noise 2 : Man Eaten
       lsr                        ;2 Divide note count by 2
       adc    #$08                ;2
       tay                        ;2
       lda    NoteCnt             ;3
       eor    #$0F                ;2
NoiseSaveX:
       ldx    #$06                ;2
NoiseSave:
       sta    AUDF0               ;3 Store in frequency for channel 0
       stx    AUDC0               ;3 Set a noise on channel 0
NoiseSaveVolume:
       sty    AUDV0               ;3 Set volume on channel 0
       rts                        ;6
 
 
  IF SIMULATE_CHALISE_FLASH
ChaliseState:
       .byte $00          ;State 0
       .word GfxChallise
       .byte $01          ;State 1
       .word GfxChallise2
       .byte $02          ;State 2
       .word GfxChallise3
       .byte $03          ;State 3
       .word GfxChallise4
       .byte $04          ;State 4
       .word GfxChallise5
       .byte $05          ;State 5
       .word GfxChallise6
       .byte $06          ;State 6
       .word GfxChallise7
       .byte $FF          ;State FF
       .word GfxChallise8
  ENDIF
 
 
  IF ROTATING_SWORD
CarryXtbl: ;# of pixels to carry sword away from ball horizontally
       .byte $FF ;invalid
       .byte $FF ;invalid
       .byte $FF ;invalid
       .byte $FF ;invalid
       .byte $FF ;invalid
       .byte $02 ;right+down
       .byte $02 ;right+up
       .byte $02 ;right
       .byte $FF ;invalid
       .byte $7B ;left+down
       .byte $7B ;left+up
       .byte $7B ;left
       .byte $FF ;invalid
       .byte $7F ;down
       .byte $7F ;up
CarryYtbl: ;# of pixels to carry sword away from ball vertically
       .byte $FF ;not moving (shared)
       .byte $FF ;invalid
       .byte $FF ;invalid
       .byte $FF ;invalid
       .byte $FF ;invalid
       .byte $7D ;right+down
       .byte $03 ;right+up
       .byte $00 ;right
       .byte $FF ;invalid
       .byte $7D ;left+down
       .byte $03 ;left+up
       .byte $00 ;left
       .byte $FF ;invalid
       .byte $7D ;down
       .byte $04 ;up
       .byte $FF ;not moving
 
 
SwordStates: ;24 bytes, sword's list of states
       .byte %01010000 ;State down + right
       .word GfxSwordDR
       .byte %01100000 ;State up + right
       .word GfxSwordUR
       .byte %01110000 ;State right
       .word GfxSwordR
       .byte %10010000 ;State down + left
       .word GfxSwordDL
       .byte %10100000 ;State up + left
       .word GfxSwordUL
       .byte %10110000 ;State left
       .word GfxSwordL
       .byte %11010000 ;State down
       .word GfxSwordD
       .byte %11100000 ;State up
       .word GfxSwordU
  ENDIF
 
       ALIGN 256,0
 
Y6pixels: ;used to select intial object vertical pickup offset
       .byte $00
       .byte $FA ;-6
       .byte $06
       .byte $00
       .byte $00
       .byte $FA ;-6
       .byte $06
       .byte $00
       .byte $00
       .byte $FA ;-6
       .byte $06
       .byte $00
       .byte $00
       .byte $FA ;-6
       .byte $06
X6pixels: ;used to select intial object horizontal pickup offset
       .byte $00 ;shared
       .byte $00
       .byte $00
       .byte $00
       .byte $06
       .byte $06
       .byte $06
       .byte $06
       .byte $FA ;-6
       .byte $FA ;-6
       .byte $FA ;-6
       .byte $FA ;-6
       .byte $00
       .byte $00
       .byte $00
       .byte $00
 
 
MagnetMatrix: ;13 bytes, Magnet's "liked object" matrix
       .byte MagnetR,YKeyR          ;Yellow Key, Magnet
       .byte MagnetR,WKeyR          ;White Key, Magnet
       .byte MagnetR,BKeyR          ;Black Key, Magnet
       .byte MagnetR,SwordR         ;Sword, Magnet
       .byte MagnetR,BridgeR        ;Bridge, Magnet
       .byte MagnetR,ChalliseR      ;Challise, Magnet
ReadStick_3: ;Joystick Merge Values
       .byte $00 ;no change (zero value shared by above table)
       .byte $C0 ;no horizontal
       .byte $30 ;no vertical
 
 
AuthorInfo: ;3 bytes, Author's signature data
       .byte <(Rm1E-Rm00),$50,$69          ;Room 1E, (50, 69)
 
 
BatMatrix: ;21 bytes, Bat's "liked object" matrix
       .byte BatR,ChalliseR         ;Bat,Challise
       .byte BatR,SwordR            ;Bat,Sword
       .byte BatR,BridgeR           ;Bat,Bridge
       .byte BatR,YKeyR             ;Bat,yellow Key
       .byte BatR,WKeyR             ;Bat,White Key
       .byte BatR,BKeyR             ;Bat,Black Key
       .byte BatR,RDragonR          ;Bat,Red Dragon
       .byte BatR,YDragonR          ;Bat,yellow Dragon
       .byte BatR,GDragonR          ;Bat,Green Dragon
       .byte BatR,MagnetR           ;Bat,Magnet
Game_Start_Tbl: ;7 bytes - initial start values for the ball and note counter
       .byte $00 ;NoteCnt (shared)
       .byte <(Rm11-Rm00) ;PlayerRoom
       .byte $50 ;PlayerX
       .byte $20 ;PlayerY
       .byte <(Rm11-Rm00) ;PrevRoom
       .byte $50 ;PrevX
       .byte $20 ;PrevY
 
 
BatStates: ;6 bytes, Bat's animation list
       .byte $03 ;State contains values 0 to 7, this byte is used for first 4 frames
       .word GfxBat1
       .byte $FF ;...this byte is thus used for the next 4 frames
       .word GfxBat2
 
 
DragonDiff: ;Dragon difficulty
       .byte $D0,$E8                ;Level 1 : Am, Pro
       .byte $F0,$F6                ;Level 2 : Am, Pro
       .byte $F0,$F6                ;Level 3 : Am, Pro
 
 
CastleRoomOffsets: ;Castle Rooms (Yellow, White, Black)...the screen # of the castle itself
       .byte <(Rm11-Rm00),<(Rm0F-Rm00),<(Rm10-Rm00)
 
 
KeyOffsets: ;Keys #1, #2, #3  (Yellow, White, Black)
     .byte YKeyNumber,WKeyNumber,BKeyNumber
 
 
PortOffsets: ;Portcullis #1, #2, #3
     .byte YGateNumber,WGateNumber,BGateNumber
 
 
PortInfo1: ;Yellow castle's portcullis
       .byte <(Rm11-Rm00),$4D,$31            ;Room number, X, Y
PortInfo2: ;White castle's portcullis
       .byte <(Rm0F-Rm00),$4D,$31            ;Room number, X, Y
PortInfo3: ;Black castle's portcullis
       .byte <(Rm10-Rm00),$4D,$31            ;Room number, X, Y
 
 
PortStates: ;39 bytes, Portcullis animation list
       .byte $04 ;State 04 -Open
       .word GfxPort07
       .byte $08 ;State 08
       .word GfxPort06
       .byte $0C ;State 0C
       .word GfxPort05
       .byte $10 ;State 10
       .word GfxPort04
       .byte $14 ;State 14
       .word GfxPort03
       .byte $18 ;State 18
       .word GfxPort02
       .byte $1C ;State 1C -Closed
       .word GfxPort01
       .byte $20 ;State 20
       .word GfxPort02
       .byte $24 ;State 24
       .word GfxPort03
       .byte $28 ;State 28
       .word GfxPort04
       .byte $2C ;State 2C
       .word GfxPort05
       .byte $30 ;State 30
       .word GfxPort06
       .byte $FF ;State FF -Open
       .word GfxPort07
 
 
  IF USE_TITLE_DISPLAY = 0
NumberStates: ;9 bytes, game select number token states
       .byte $01 ;State 1
       .word GfxNum1
       .byte $03 ;State 2
       .word GfxNum2
       .byte $FF ;State 3
       .word GfxNum3
  ENDIF
 
;NOTE: Game1Objects and Game2Objects must hold the same number of bytes
;currently 102 bytes total for both tables
Game1Objects: ;Object locations (room and co-ordinate) for game 1
       .byte <(Rm02-Rm00),$4D,$20             ;Map portal (room,X,Y)
       .byte <(Rm15-Rm00),$51,$12             ;Black dot (Room,X,Y)
       .byte <(Rm0E-Rm00),$50,$20,$00,$00     ;Red Dragon (Room,X,Y,Movement,State)
       .byte <(Rm01-Rm00),$50,$20,$00,$00     ;Yellow Dragon (Room,X,Y,Movement,State)
       .byte <(Rm1D-Rm00),$50,$20,$00,$00     ;Green Dragon (Room,X,Y,Movement,State)
       .byte <(Rm1B-Rm00),$80,$20             ;Magnet (Room,X,Y)
       .byte <(Rm12-Rm00),$20,$20             ;Sword (Room,X,Y)
       .byte <(Rm1C-Rm00),$30,$20             ;Challise (Room,X,Y)
       .byte <(Rm04-Rm00),$29,$37             ;Bridge (Room,X,Y)
       .byte <(Rm11-Rm00),$20,$40             ;Yellow Key (Room,X,Y)
       .byte <(Rm0E-Rm00),$20,$40             ;White Key (Room,X,Y)
       .byte <(Rm1D-Rm00),$20,$40             ;Black Key (Room,X,Y)
       .byte $1C                              ;Portcullis State (closed)
       .byte $1C                              ;Portcullis State (closed)
       .byte $1C                              ;Portcullis State (closed)
       .byte <(Rm1A-Rm00),$20,$20,$00,$00,$78 ;Bat (Room,X,Y,Movement,State/Fed-up,Carrying)
Game2Objects: ;...Games 2 & 3
       .byte <(Rm02-Rm00),$4D,$20             ;Map portal (room,X,Y)
       .byte <(Rm15-Rm00),$51,$12             ;Black Dot (Room,X,Y)
       .byte <(Rm14-Rm00),$50,$20,$A0,$00     ;Red Dragon (Room,X,Y,Movement,State)
       .byte <(Rm19-Rm00),$50,$20,$A0,$00     ;Yellow Dragon (Room,X,Y,Movement,State)
       .byte <(Rm04-Rm00),$50,$20,$A0,$00     ;Green Dragon (Room,X,Y,Movement,State)
       .byte <(Rm0E-Rm00),$80,$20             ;Magnet (Room,X,Y)
       .byte <(Rm11-Rm00),$20,$20             ;Sword (Room,X,Y)
       .byte <(Rm14-Rm00),$30,$20             ;Challise (Room,X,Y)
       .byte <(Rm0B-Rm00),$40,$40             ;Bridge (Room,X,Y)
       .byte <(Rm09-Rm00),$20,$40             ;Yellow Key (Room,X,Y)
       .byte <(Rm06-Rm00),$20,$40             ;White Key (Room,X,Y)
       .byte <(Rm19-Rm00),$20,$40             ;Black Key (Room,X,Y)
       .byte $1C                              ;Portcullis State (closed)
       .byte $1C                              ;Portcullis State (closed)
       .byte $1C                              ;Portcullis State (closed)
       .byte <(Rm02-Rm00),$20,$20,$90,$00,$78 ;Bat (Room,X,Y,Movement,State/Fed-up,Carrying)
 
       ALIGN 256,0
 
;NOTE: All dragon matrices must be on the same page
;      If an object is listed before the dragon, it is "feared"
;      If an object is listed after the dragon, it is "guarded"
RedDragMatrix: ;Red dragon object matrix
       .byte SwordR,RDragonR        ;Sword, Red Dragon
       .byte RDragonR,PlayerRoom    ;Red Dragon, Ball
       .byte RDragonR,ChalliseR     ;Red Dragon, Challise
       .byte RDragonR,WKeyR         ;Red Dragon, White Key
RDragonStates: ;12 bytes, list of states for all dragons
       .byte $00 ;State 00 (roaming), first byte shared w/previous
       .word GfxRDrag0
  IF ANIMATE_DRAGON
       .byte $01 ;State 00 (roaming), first byte shared w/previous
       .word GfxRDrag0a
       .byte $03 ;State 01 (dead)
       .word GfxRDrag2
       .byte $04 ;State 02 (swallowed player)
  ELSE
       .byte $01 ;State 01 (dead)
       .word GfxRDrag2
       .byte $02 ;State 02 (swallowed player)
  ENDIF
       .word GfxRDrag0
       .byte $FF ;State FF (biting player)
       .word GfxRDrag1
 
 
YelDragMatrix: ;Yellow dragon's object matrix
       .byte SwordR,YDragonR        ;Sword, Yellow Dragon
       .byte YKeyR,YDragonR         ;Yellow Key, Yellow Dragon
       .byte YDragonR,PlayerRoom    ;Yellow Dragon, Ball
       .byte YDragonR,ChalliseR     ;Yellow Dragon, Challise
YDragonStates: ;12 bytes, list of states for all dragons
       .byte $00 ;State 00 (roaming), first byte shared w/previous
       .word GfxYDrag0
  IF ANIMATE_DRAGON
       .byte $01 ;State 01 (roaming)
       .word GfxYDrag0a
       .byte $03 ;State 02-3 (dead)
       .word GfxYDrag2
       .byte $04 ;State 04 (swallowed player)
  ELSE
       .byte $01 ;State 01 (dead)
       .word GfxYDrag2
       .byte $02 ;State 02 (swallowed player)
  ENDIF
       .word GfxYDrag0
       .byte $FF ;State 03/05-FF (biting player)
       .word GfxYDrag1
 
 
GreenDragonMatrix: ;Green dragon's object matrix
       .byte SwordR,GDragonR        ;Sword, Green Dragon
       .byte GDragonR,PlayerRoom    ;Green Dragon, Ball
       .byte GDragonR,ChalliseR     ;Green Dragon Challise
       .byte GDragonR,BridgeR       ;Green Dragon, Bridge
       .byte GDragonR,MagnetR       ;Green Dragon, Magnet
       .byte GDragonR,BKeyR         ;Green Dragon, Black Key
GDragonStates: ;12 bytes, list of states for all dragons
       .byte $00 ;State 00 (roaming), first byte shared w/previous
       .word GfxGDrag0
  IF ANIMATE_DRAGON
       .byte $01 ;State 00 (roaming), first byte shared w/previous
       .word GfxGDrag0a
       .byte $03 ;State 01 (dead)
       .word GfxGDrag2
       .byte $04 ;State 02 (swallowed player)
  ELSE
       .byte $01 ;State 01 (dead)
       .word GfxGDrag2
       .byte $02 ;State 02 (swallowed player)
  ENDIF
       .word GfxGDrag0
       .byte $FF ;State FF (biting player)
       .word GfxGDrag1
 
 
  IF USE_TITLE_DISPLAY = 0
NumberInfo: ;Game selection digit location...
       .byte $00,$50,$40          ;#5 Number: Room 00,(50,40)
  ENDIF
 
Object_Data_LSB: ;LSB of object room/x/y table (or ram location of room #'s)
;NOTE: NullData must be listed first!
NullData:         .byte <NullR              ;$00 Null object's room (LSB)
YGateData:        .byte <PortInfo1          ;$01 Yellow castle gate's room (LSB)
WGateData:        .byte <PortInfo2          ;$02 White castle gate's room (LSB)
BGateData:        .byte <PortInfo3          ;$03 Black castle gate's room (LSB)
MapPortData:      .byte <MapPortR           ;    Map portal's room (LSB)
SurroundData:     .byte <SurroundR          ;$04 Invisible Surround's room (LSB)
AuthorData:       .byte <AuthorInfo         ;$05 Author signature's room (LSB)
  IF USE_TITLE_DISPLAY = 0
NumberData:       .byte <NumberInfo         ;$06 Game selection digit's room (LSB)
  ENDIF
RDragonData:      .byte <RDragonR           ;$07 Red Dragon's room (LSB)
YDragonData:      .byte <YDragonR           ;$08 Yellow Dragon's room (LSB)
GDragonData:      .byte <GDragonR           ;$09 Green Dragon's room (LSB)
SwordData:        .byte <SwordR             ;$0A Sword's room (LSB)
BridgeData:       .byte <BridgeR            ;$0B Bridge's room (LSB)
YKeyData:         .byte <YKeyR              ;$0C Yellow key's room (LSB)
WKeyData:         .byte <WKeyR              ;$0D White key's room (LSB)
BKeyData:         .byte <BKeyR              ;$0E Black key's room (LSB)
BatData:          .byte <BatR               ;$0F Bat's room (LSB)
DotData:          .byte <DotR               ;$10 Secret dot's room (LSB)
ChalliseData:     .byte <ChalliseR          ;$11 Challise's room (LSB)
MagnetData:       .byte <MagnetR            ;$12 Magnet's room (LSB)
 
 
Object_Data_MSB: ;MSB of object room/x/y table (zero if ram) | Size of object ; object#
;Sprite size (Picture shows shape, 8 pixels per character)0
;SIZE0  One copy              (X........) single 8-pixel copy
;SIZE1  Two copies - close    (X.X......) eight pixels between 8-pixel copies
;SIZE2  Two copies - medium   (X...X....) twenty-four pixels between 8-pixel copies
;SIZE3  Three copies - close  (X.X.X....) eight pixels between 8-pixel copies
;SIZE4  Two copies - wide     (X.......X) fifty-six pixels between 8-pixel copies
;SIZE5  Double sized player   (XX.......) single 16-pixel copy
;SIZE6  Three copies - medium (X...X...X) twenty-four pixels between 8-pixel copies
;SIZE7  Quad sized player     (XXXX.....) single 32-pixel copy
       .byte $00               | SIZE0 ;$00 Null object's room (MSB)           Single width
       .byte (>PortInfo1)&$1F  | SIZE0 ;$01 Yellow castle gate's room (MSB)    Single width
       .byte (>PortInfo2)&$1F  | SIZE0 ;$02 White castle gate's room (MSB)     Single width
       .byte (>PortInfo3)&$1F  | SIZE0 ;$03 Black castle gate's room (MSB)     Single width
       .byte $00               | SIZE0 ;    Map portal's room (MSB)            Single width
       .byte $00               | SIZE7 ;$04 Invisible Surround's room (MSB) Quadruple width
       .byte (>AuthorInfo)&$1F | SIZE0 ;$05 Author signature's room (MSB)      Single width
  IF USE_TITLE_DISPLAY = 0
       .byte (>NumberInfo)&$1F | SIZE0 ;$06 Game selection digit's room (MSB)  Single width
  ENDIF
       .byte $00               | SIZE0 ;$07 Red Dragon's room (MSB)            Single width
       .byte $00               | SIZE0 ;$08 Yellow Dragon's room (MSB)         Single width
       .byte $00               | SIZE0 ;$09 Green Dragon's room (MSB)          Single width
       .byte $00               | SIZE0 ;$0A Sword's room (MSB)                 Single width
       .byte $00               | SIZE7 ;$0B Bridge's room (MSB)             Quadruple width
       .byte $00               | SIZE0 ;$0C Yellow key's room (MSB)            Single width
       .byte $00               | SIZE0 ;$0D White key's room (MSB)             Single width
       .byte $00               | SIZE0 ;$0E Black key's room (MSB)             Single width
       .byte $00               | SIZE0 ;$0F Bat's room (MSB)                   Single width
       .byte $00               | SIZE0 ;$10 Secret dot's room (MSB)            Single width
       .byte $00               | SIZE0 ;$11 Challise's room (MSB)              Single width
       .byte $00               | SIZE0 ;$12 Magnet's room (MSB)                Single width
 
 
Object_State_LSB: ;ram$addr of state for animated sprites, gfx$addr LSB for static objects...
       .byte <GfxNull      ;$00 Null object's state (LSB)
       .byte <YGateR       ;$01 Yellow castle gate's state (LSB)
       .byte <WGateR       ;$02 White castle gate's state (LSB)
       .byte <BGateR       ;$03 Black castle gate's state (LSB)
       .byte <GfxMapPort   ;    Map portal's state (LSB)
       .byte <GfxSurround  ;$04 Invisible Surround's state (LSB)
       .byte <GfxAuthor    ;$05 Author signature's state (LSB)
  IF USE_TITLE_DISPLAY = 0
       .byte <Level        ;$06 Game selection digit's state (LSB)
  ENDIF
       .byte <RDragonR+4   ;$07 Red Dragon's state (LSB)
       .byte <YDragonR+4   ;$08 Yellow Dragon's state (LSB)
       .byte <GDragonR+4   ;$09 Green Dragon's state (LSB)
  IF ROTATING_SWORD
       .byte <SwordState   ;$0A Sword's state (LSB)
  ELSE
       .byte <GfxSwordL    ;$0A Sword's state (LSB)
  ENDIF
       .byte <GfxBridge    ;$0B Bridge's state (LSB)
       .byte <GfxYKey      ;$0C Yellow key's state (LSB)
       .byte <GfxWKey      ;$0D White key's state (LSB)
       .byte <GfxBKey      ;$0E Black key's state (LSB)
       .byte <BatR+4       ;$0F Bat's state (LSB)
       .byte <GfxDot       ;$10 Secret dot's state (LSB)
  IF SIMULATE_CHALISE_FLASH
       .byte <BatR+4       ;$0F Bat's state (LSB)
  ELSE
       .byte <GfxChallise  ;$11 Challise's state (LSB)
  ENDIF
       .byte <GfxMagnet    ;$12 Magnet's state (LSB)
 
 
Object_State_MSB: ;$00 for animated sprites, gfx$addr MSB for static objects...
       .byte >GfxNull      ;$00 Null object's state (MSB)
       .byte $00           ;$01 Yellow castle gate's state (MSB)
       .byte $00           ;$02 White castle gate's state (MSB)
       .byte $00           ;$03 Black castle gate's state (MSB)
       .byte >GfxMapPort   ;    Map portal's state (MSB)
       .byte >GfxSurround  ;$04 Invisible Surround's state (MSB)
       .byte >GfxAuthor    ;$05 Author signature's state (MSB)
  IF USE_TITLE_DISPLAY = 0
       .byte $00           ;$06 Game selection digit's state (MSB)
  ENDIF
       .byte $00           ;$07 Red Dragon's state (MSB)
       .byte $00           ;$08 Yellow Dragon's state (MSB)
       .byte $00           ;$09 Green Dragon's state (MSB)
  IF ROTATING_SWORD
       .byte $00           ;$0A Sword's state (MSB)
  ELSE
       .byte >GfxSwordL    ;$0A Sword's state (MSB)
  ENDIF
       .byte >GfxBridge    ;$0B Bridge's state (MSB)
       .byte >GfxYKey      ;$0C Yellow key's state (MSB)
       .byte >GfxWKey      ;$0D White key's state (MSB)
       .byte >GfxBKey      ;$0E Black key's state (MSB)
       .byte $00           ;$0F Bat's state (MSB)
       .byte >GfxDot       ;$10 Secret dot's state (MSB)
  IF SIMULATE_CHALISE_FLASH
       .byte $00           ;$0F Bat's state (MSB)
  ELSE
       .byte >GfxChallise  ;$11 Challise's state (MSB)
  ENDIF
       .byte >GfxMagnet    ;$12 Magnet's state (MSB)
 
 
State_List_LSB: ;only used for animated sprites...
       .byte $00           ;$00 Null object's list of states (LSB)
       .byte <PortStates   ;$01 Yellow castle gate's list of states (LSB)
       .byte <PortStates   ;$02 White castle gate's list of states (LSB)
       .byte <PortStates   ;$03 Black castle gate's list of states (LSB)
       .byte $00           ;    Map portal's list of states (LSB)
       .byte $00           ;$04 Invisible Surround's list of states (LSB)
       .byte $00           ;$05 Author signature's list of states (LSB)
  IF USE_TITLE_DISPLAY = 0
       .byte <NumberStates ;$06 Game selection digit's list of states (LSB)
  ENDIF
       .byte <RDragonStates;$07 Red Dragon's list of states (LSB)
       .byte <YDragonStates;$08 Yellow Dragon's list of states (LSB)
       .byte <GDragonStates;$09 Green Dragon's list of states (LSB)
  IF ROTATING_SWORD
       .byte <SwordStates  ;$0A Sword's list of states (LSB)
  ELSE
       .byte $00           ;$0A Sword's list of states (LSB)
  ENDIF
       .byte $00           ;$0B Bridge's list of states (LSB)
       .byte $00           ;$0C Yellow key's list of states (LSB)
       .byte $00           ;$0D White key's list of states (LSB)
       .byte $00           ;$0E Black key's list of states (LSB)
       .byte <BatStates    ;$0F Bat's list of states (LSB)
       .byte $00           ;$10 Secret dot's list of states (LSB)
  IF SIMULATE_CHALISE_FLASH
       .byte <ChaliseState ;$0F Chalise list of states (LSB)
  ELSE
       .byte $00           ;$11 Challise's list of states (LSB)
  ENDIF
       .byte $00           ;$12 Magnet's list of states (LSB)
 
 
State_List_MSB: ;only used for animated sprites...
       .byte $00           ;$00 Null object's list of states (MSB)
       .byte >PortStates   ;$01 Yellow castle gate's list of states (MSB)
       .byte >PortStates   ;$02 White castle gate's list of states (MSB)
       .byte >PortStates   ;$03 Black castle gate's list of states (MSB)
       .byte $00           ;    Map portal's list of states (MSB)
       .byte $00           ;$04 Invisible Surround's list of states (MSB)
       .byte $00           ;$05 Author signature's list of states (MSB)
  IF USE_TITLE_DISPLAY = 0
       .byte >NumberStates ;$06 Game selection digit's list of states (MSB)
  ENDIF
       .byte >RDragonStates;$07 Red Dragon's list of states (MSB)
       .byte >YDragonStates;$08 Yellow Dragon's list of states (MSB)
       .byte >GDragonStates;$09 Green Dragon's list of states (MSB)
  IF ROTATING_SWORD
       .byte >SwordStates  ;$0A Sword's list of states (MSB)
  ELSE
       .byte $00           ;$0A Sword's list of states (MSB)
  ENDIF
       .byte $00           ;$0B Bridge's list of states (MSB)
       .byte $00           ;$0C Yellow key's list of states (MSB)
       .byte $00           ;$0D White key's list of states (MSB)
       .byte $00           ;$0E Black key's list of states (MSB)
       .byte >BatStates    ;$0F Bat's list of states (MSB)
       .byte $00           ;$10 Secret dot's list of states (MSB)
  IF SIMULATE_CHALISE_FLASH
       .byte >ChaliseState ;$0F Chalise list of states (MSB)
  ELSE
       .byte $00           ;$11 Challise's list of states (MSB)
  ENDIF
       .byte $00           ;$12 Magnet's list of states (MSB)
 
 
Level1Diffs: ;Map differences for level 1
;These "RD" tags used in the room matrix...subtract RD0 to get proper $80 value
RD1:   .byte <(Rm10-Rm00) ;Down from Room $01 Below Hedge maze -> Outside black Castle
RD2:   .byte <(Rm05-Rm00) ;Down from Room $02 Below yellow castle -> Hedge maze above entry
RD3:   .byte <(Rm1D-Rm00) ;Down from Room 03 Above the catacombs -> Under right corridor
RD4:   .byte <(Rm1C-Rm00) ;ULRD from $1B in black castle -> Above right corr. (r of catacombs)
RD5:   .byte <(Rm1B-Rm00) ;Down from Room $1C Above right corr. -> Just inside black castle
RD6:   .byte <(Rm03-Rm00) ;Up from Room $1D Under right corridor -> Above the catacombs
 
 
Level2Diffs: ;Map differences for level 2
Level3Diffs: ;Map differences for level 3
       .byte <(Rm0F-Rm00) ;Down from Room $01 Below Hedge maze -> Outside white Castle
       .byte <(Rm11-Rm00) ;Down from Room $02 Below yellow castle -> Outside yellow Castle
       .byte <(Rm0A-Rm00) ;Down from Room 03 Above the catacombs -> Catacombs entry
       .byte <(Rm16-Rm00) ;ULRD from $1B in black castle -> Black maze entry
       .byte <(Rm0C-Rm00) ;Down from Room $1C Above right corr. -> Right corr (r of catacombs)
       .byte <(Rm0C-Rm00) ;Up from Room $1D Under right corridor -> Right corr (r of catacombs)
 
 
  IF FIX_RANDOM
Room_Bounds_Tbl: ;Room Bounds Data...range of room #'s for random object placement in game 3
       .byte ChalliseR,$02,$0A ;Challise, minimum screen#, maximum screen#
       .byte YKeyR,$02,$1D     ;Yellow Key
       .byte BKeyR,$07,$1D     ;Black Key
       .byte WKeyR,$0B,$1D     ;White Key
       .byte RDragonR,$01,$1D  ;Red Dragon
       .byte YDragonR,$01,$1D  ;Yellow Dragon
       .byte GDragonR,$01,$1D  ;Green Dragon
       .byte SwordR,$01,$1D    ;Sword
       .byte BridgeR,$01,$1D   ;Bridge
       .byte BatR,$01,$1D      ;Bat
       .byte MagnetR,$01,$1D   ;Magnet
  ELSE
Room_Bounds_Tbl: ;Room Bounds Data...range of room #'s for random object placement in game 3
       .byte ChalliseR,$13,$1A ;Challise, minimum screen#, maximum screen#
       .byte RDragonR,$01,$1D  ;Red Dragon
       .byte YDragonR,$01,$1D  ;Yellow Dragon
       .byte GDragonR,$01,$1D  ;Green Dragon
       .byte SwordR,$01,$1D    ;Sword
       .byte BridgeR,$01,$1D   ;Bridge
       .byte YKeyR,$01,$1D     ;Yellow Key
       .byte WKeyR,$01,$16     ;White Key
       .byte BKeyR,$01,$12     ;Black Key
       .byte BatR,$01,$1D      ;Bat
       .byte MagnetR,$01,$1D   ;Magnet
  ENDIF
Object_Map_Tbl: ;must immediately follow Room_Bounds_Tbl
       .word Game1Objects           ;object template for first game
       .word Game2Objects           ;object template for second
       .word Game2Objects           ;(reuse second for third before randomization)
 
 
EntryRoomOffsets: ;Castle Entry Rooms (Yellow, White, Black)...the 1st screen inside a castle
     .byte <(Rm12-Rm00),<(Rm1A-Rm00),<(Rm1B-Rm00)
 
       ALIGN 256
 
Xeor: ;used for all object movement
       .byte $80
       .byte $80
       .byte $80
       .byte $80
       .byte $80
       .byte $00
       .byte $00
       .byte $00
       .byte $80
       .byte $FF
       .byte $FF
       .byte $FF
Yeor: ;used for all object movement
       .byte $80 ;shared
       .byte $80 ;shared
       .byte $80 ;shared
       .byte $80 ;shared
       .byte $80
       .byte $FF
       .byte $00
       .byte $80
       .byte $80
       .byte $FF
       .byte $00
       .byte $80
       .byte $80
       .byte $FF
       .byte $00
       .byte $80
 
  IF FIX_RANDOM
 
RoomGFX_LSB_Tbl: ;LSB of gfx ;room#, description
Rm00:
    IF USE_TITLE_DISPLAY = 0
           .byte <Room00     ;old $00, new $00 Number room
    ENDIF
Rm12:      .byte <Room12     ;old $12, new $01 Inside yellow castle
Rm1B:      .byte <Room1B     ;old $1B, new $02 Just inside black castle
Rm13:      .byte <Room13     ;old $13, new $03 Black maze right of entry
Rm14:      .byte <Room14     ;old $14, new $04 Black maze challise room
Rm15:      .byte <Room15     ;old $15, new $05 Black maze dot's room
Rm16:      .byte <Room16     ;old $16, new $06 Black maze entry
Rm17:      .byte <Room17     ;old $17, new $07 Red maze above black key's room
Rm18:      .byte <Room18     ;old $18, new $08 Red maze above entry
Rm19:      .byte <Room19     ;old $19, new $09 Red maze black key's room
Rm1A:      .byte <Room1A     ;old $1A, new $0A Red maze entry
Rm01:      .byte <Room01     ;old $01, new $0B Below Hedge maze
Rm02:      .byte <Room02     ;old $02, new $0C Below yellow castle
Rm03:      .byte <Room03     ;old $03, new $0D Above the catacombs
Rm04:      .byte <Room04     ;old $04, new $0E Hedge maze below black castle
Rm05:      .byte <Room05     ;old $05, new $0F Hedge maze above entry
Rm06:      .byte <Room06     ;old $06, new $10 Hedge maze bottom
Rm07:      .byte <Room07     ;old $07, new $11 Hedge maze center
Rm08:      .byte <Room08     ;old $08, new $12 Hedge maze entry
Rm09:      .byte <Room09     ;old $09, new $13 Catacombs middle
Rm0A:      .byte <Room0A     ;old $0A, new $14 Catacombs entry
Rm0B:      .byte <Room0B     ;old $0B, new $15 Catacombs side
Rm0C:      .byte <Room0C     ;old $0C, new $16 Right corridor right of catacombs
Rm0D:      .byte <Room0D     ;old $0D, new $17 Left corridor below white Castle
Rm0E:      .byte <Room0E     ;old $0E, new $18 Below left corridor
Rm0F:      .byte <Room0F     ;old $0F, new $19 Outside white Castle
Rm10:      .byte <Room10     ;old $10, new $1A Outside black Castle
Rm11:      .byte <Room11     ;old $11, new $1B Outside yellow Castle
Rm1C:      .byte <Room1C     ;old $1C, new $1C Above right corridor right of catacombs
Rm1D:      .byte <Room1D     ;old $1D, new $1D Under right corridor
Rm1E:      .byte <Room1E     ;old $1E, new $1E Warren Robinett's room
 
 
RoomGFX_MSB_Tbl: ;MSB of gfx ;room#, description
;           Bit 5-7 ($20/$40/$80): bank number where room GFX exists
;           Bit 4   (+$10): False if surround object needed
    IF USE_TITLE_DISPLAY = 0
       .byte (>Room00)&$0F | BANK0            ;$00 Number room
    ENDIF
       .byte (>Room12)&$0F | BANK0            ;$12 Inside yellow castle
       .byte (>Room1B)&$0F | BANK0            ;$1B Just inside black castle
       .byte (>Room13)&$0F | BANK0 | SURROUND ;$13 Black maze right of entry
       .byte (>Room14)&$0F | BANK0 | SURROUND ;$14 Black maze challise room
       .byte (>Room15)&$0F | BANK0 | SURROUND ;$15 Black maze dot's room
       .byte (>Room16)&$0F | BANK0 | SURROUND ;$16 Black maze entry
       .byte (>Room17)&$0F | BANK0            ;$17 Red maze above black key's room
       .byte (>Room18)&$0F | BANK0            ;$18 Red maze above entry
       .byte (>Room19)&$0F | BANK0            ;$19 Red maze black key's room
       .byte (>Room1A)&$0F | BANK0            ;$1A Red maze entry
       .byte (>Room01)&$0F | BANK0            ;$01 Below Hedge maze
       .byte (>Room02)&$0F | BANK0            ;$02 Below yellow castle
       .byte (>Room03)&$0F | BANK0            ;$03 Above the catacombs
       .byte (>Room04)&$0F | BANK0            ;$04 Hedge maze below black castle
       .byte (>Room05)&$0F | BANK0            ;$05 Hedge maze above entry
       .byte (>Room06)&$0F | BANK0            ;$06 Hedge maze bottom
       .byte (>Room07)&$0F | BANK0            ;$07 Hedge maze center
       .byte (>Room08)&$0F | BANK0            ;$08 Hedge maze entry
       .byte (>Room09)&$0F | BANK0 | SURROUND ;$09 Catacombs middle
       .byte (>Room0A)&$0F | BANK0 | SURROUND ;$0A Catacombs entry
       .byte (>Room0B)&$0F | BANK0 | SURROUND ;$0B Catacombs side
       .byte (>Room0C)&$0F | BANK0            ;$0C Right corridor right of catacombs
       .byte (>Room0D)&$0F | BANK0            ;$0D Left corridor below white Castle
       .byte (>Room0E)&$0F | BANK0            ;$0E Below left corridor
       .byte (>Room0F)&$0F | BANK0            ;$0F Outside white Castle
       .byte (>Room10)&$0F | BANK0            ;$10 Outside black Castle
       .byte (>Room11)&$0F | BANK0            ;$11 Outside yellow Castle
       .byte (>Room1C)&$0F | BANK0            ;$1C Above right corridor right of catacombs
       .byte (>Room1D)&$0F | BANK0            ;$1D Under right corridor
       .byte (>Room1E)&$0F | BANK0            ;$1E Warren Robinett's room
 
 
    IF MONOCOLOR
;NOTE: the following table is not used for Multicolor mode (so walls are unable to flash there)
      IF PAL
Wall_Color_Tbl: ;playfield color ;room#, description...if an odd number, room is to Flash
       IF USE_TITLE_DISPLAY = 0
       .byte $A6     ;$00 Number room
       ENDIF
       .byte $2C     ;$12 Inside yellow castle
       .byte $46     ;$1B Just inside black castle
       .byte $08     ;$13 Black maze right of entry
       .byte $08     ;$14 Black maze challise room
       .byte $08     ;$15 Black maze dot's room
       .byte $08     ;$16 Black maze entry
       .byte $46     ;$17 Red maze above black key's room
       .byte $46     ;$18 Red maze above entry
       .byte $46     ;$19 Red maze black key's room
       .byte $46     ;$1A Red maze entry
       .byte $38     ;$01 Below blue maze
       .byte $58     ;$02 Below yellow castle
       .byte $3A     ;$03 Above the catacombs
       .byte $D6     ;$04 Blue maze below black castle
       .byte $D6     ;$05 Blue maze above entry
       .byte $D6     ;$06 Blue maze bottom
       .byte $D6     ;$07 Blue maze center
       .byte $D6     ;$08 Blue maze entry
       .byte $08     ;$09 Catacombs middle
       .byte $08     ;$0A Catacombs entry
       .byte $08     ;$0B Catacombs side
       .byte $B8     ;$0C Right corridor right of catacombs
       .byte $78     ;$0D Left corridor below white Castle
       .byte $98     ;$0E Below left corridor
       .byte $0C     ;$0F Outside white Castle
       .byte $00     ;$10 Outside black Castle
       .byte $2C     ;$11 Outside yellow Castle
       .byte $A6     ;$1C Above right corridor right of catacombs
       .byte $46     ;$1D Under right corridor
       .byte $A6     ;$1E Warren Robinett's room
      ELSE
Wall_Color_Tbl: ;playfield color ;room#, description...if an odd number, room is to Flash
       IF USE_TITLE_DISPLAY = 0
       .byte $66     ;$00 Number room
       ENDIF
       .byte $1A     ;$12 Inside yellow castle
       .byte $36     ;$1B Just inside black castle
       .byte $08     ;$13 Black maze right of entry
       .byte $08     ;$14 Black maze challise room
       .byte $08     ;$15 Black maze dot's room
       .byte $08     ;$16 Black maze entry
       .byte $36     ;$17 Red maze above black key's room
       .byte $36     ;$18 Red maze above entry
       .byte $36     ;$19 Red maze black key's room
       .byte $36     ;$1A Red maze entry
       .byte $D8     ;$01 Below blue maze
       .byte $C8     ;$02 Below yellow castle
       .byte $E8     ;$03 Above the catacombs
       .byte $86     ;$04 Blue maze below black castle
       .byte $86     ;$05 Blue maze above entry
       .byte $86     ;$06 Blue maze bottom
       .byte $86     ;$07 Blue maze center
       .byte $86     ;$08 Blue maze entry
       .byte $08     ;$09 Catacombs middle
       .byte $08     ;$0A Catacombs entry
       .byte $08     ;$0B Catacombs side
       .byte $98     ;$0C Right corridor right of catacombs
       .byte $B8     ;$0D Left corridor below white Castle
       .byte $A8     ;$0E Below left corridor
       .byte $0C     ;$0F Outside white Castle
       .byte $00     ;$10 Outside black Castle
       .byte $1A     ;$11 Outside yellow Castle
       .byte $66     ;$1C Above right corridor right of catacombs
       .byte $36     ;$1D Under right corridor
       .byte $66     ;$1E Warren Robinett's room
      ENDIF
    ENDIF
 
 
    IF USE_UNIQUE_BACKGROUND_COLORS
      IF PAL
Ground_Color_Tbl: ;if an odd number, background is to Flash
       IF USE_TITLE_DISPLAY = 0
       .byte $08     ;$00 Number room
       ENDIF
       .byte $08     ;$12 Inside yellow castle
       .byte $08     ;$1B Just inside black castle
       .byte $08     ;$13 Black maze right of entry
       .byte $08     ;$14 Black maze challise room
       .byte $08     ;$15 Black maze dot's room
       .byte $08     ;$16 Black maze entry
       .byte $08     ;$17 Red maze above black key's room
       .byte $08     ;$18 Red maze above entry
       .byte $08     ;$19 Red maze black key's room
       .byte $08     ;$1A Red maze entry
       .byte $08     ;$01 Below Hedge maze
       .byte $08     ;$02 Below yellow castle
       .byte $08     ;$03 Above the catacombs
       .byte $08     ;$04 Hedge maze below black castle
       .byte $08     ;$05 Hedge maze above entry
       .byte $08     ;$06 Hedge maze bottom
       .byte $08     ;$07 Hedge maze center
       .byte $08     ;$08 Hedge maze entry
       .byte $08     ;$09 Catacombs middle
       .byte $08     ;$0A Catacombs entry
       .byte $08     ;$0B Catacombs side
       .byte $08     ;$0C Right corridor right of catacombs
       .byte $08     ;$0D Left corridor below white Castle
       .byte $08     ;$0E Below left corridor
       .byte $08     ;$0F Outside white Castle
       .byte $08     ;$10 Outside black Castle
       .byte $08     ;$11 Outside yellow Castle
       .byte $08     ;$1C Above right corridor right of catacombs
       .byte $08     ;$1D Under right corridor
       .byte $08     ;$1E Warren Robinett's room
    ELSE
Ground_Color_Tbl: ;if an odd number, background is to Flash
       IF USE_TITLE_DISPLAY = 0
       .byte $08     ;$00 Number room
       ENDIF
       .byte $08     ;$12 Inside yellow castle
       .byte $08     ;$1B Just inside black castle
       .byte $08     ;$13 Black maze right of entry
       .byte $08     ;$14 Black maze challise room
       .byte $08     ;$15 Black maze dot's room
       .byte $08     ;$16 Black maze entry
       .byte $08     ;$17 Red maze above black key's room
       .byte $08     ;$18 Red maze above entry
       .byte $08     ;$19 Red maze black key's room
       .byte $08     ;$1A Red maze entry
       .byte $08     ;$01 Below Hedge maze
       .byte $08     ;$02 Below yellow castle
       .byte $08     ;$03 Above the catacombs
       .byte $08     ;$04 Hedge maze below black castle
       .byte $08     ;$05 Hedge maze above entry
       .byte $08     ;$06 Hedge maze bottom
       .byte $08     ;$07 Hedge maze center
       .byte $08     ;$08 Hedge maze entry
       .byte $08     ;$09 Catacombs middle
       .byte $08     ;$0A Catacombs entry
       .byte $08     ;$0B Catacombs side
       .byte $08     ;$0C Right corridor right of catacombs
       .byte $08     ;$0D Left corridor below white Castle
       .byte $08     ;$0E Below left corridor
       .byte $08     ;$0F Outside white Castle
       .byte $08     ;$10 Outside black Castle
       .byte $08     ;$11 Outside yellow Castle
       .byte $08     ;$1C Above right corridor right of catacombs
       .byte $08     ;$1D Under right corridor
       .byte $08     ;$1E Warren Robinett's room
      ENDIF
    ENDIF
 
North_Map_Tbl: ;room to the North ;room#, description (from -> to)
    IF USE_TITLE_DISPLAY = 0
       .byte $00       ;$00 Number room -> $00 Number room
    ENDIF
       .byte Rm12-Rm00 ;$12 Inside yellow castle -> $12 Inside yellow castle
       .byte RD4-RD0   ;$1B inside black castle -> 4th set of differences
       .byte Rm15-Rm00 ;$13 Black maze right of entry -> $15 Black maze dot's room
       .byte Rm16-Rm00 ;$14 Black maze challise room -> $16 Black maze entry
       .byte Rm13-Rm00 ;$15 Black maze dot's room -> $13 Black maze right of entry
       .byte Rm14-Rm00 ;$16 Black maze entry -> $14 Black maze challise room
       .byte Rm19-Rm00 ;$17 Red maze above black key's room -> $19 Red maze black key's room
       .byte Rm1A-Rm00 ;$18 Red maze above entry -> $1A Red maze entry
       .byte Rm17-Rm00 ;$19 Red maze black key's room -> $17 Red maze above black key's room
       .byte Rm18-Rm00 ;$1A Red maze entry -> $18 Red maze above entry
       .byte Rm08-Rm00 ;$01 Below Hedge maze -> $08 Hedge maze entry
       .byte Rm11-Rm00 ;$02 Below yellow castle -> $11 Outside yellow castle
       .byte Rm06-Rm00 ;$03 Above the catacombs -> $06 Hedge maze bottom
       .byte Rm10-Rm00 ;$04 Hedge maze below black castle -> $10 Outside black castle
       .byte Rm1D-Rm00 ;$05 Hedge maze above entry -> $1D Under right corridor
       .byte Rm07-Rm00 ;$06 Hedge maze bottom -> $07 Hedge maze center
       .byte Rm04-Rm00 ;$07 Hedge maze center -> $04 Hedge maze below black castle
       .byte Rm05-Rm00 ;$08 Hedge maze entry -> $05 Hedge maze above entry
       .byte Rm0A-Rm00 ;$09 Catacombs middle -> $0A Catacombs entry
       .byte Rm03-Rm00 ;$0A Catacombs entry -> $03 Above the catacombs
       .byte Rm09-Rm00 ;$0B Catacombs side -> $09 Catacombs middle
       .byte Rm1C-Rm00 ;$0C Right corridor right of catacombs -> $1C Above right corridor
       .byte Rm0F-Rm00 ;$0D Left corridor below white Castle -> $0F Outside white castle
       .byte Rm0D-Rm00 ;$0E Below left corridor -> $0D Left corridor below white castle
       .byte Rm0E-Rm00 ;$0F Outside white Castle -> $0E Below left corridor
       .byte Rm01-Rm00 ;$10 Outside black Castle -> $01 Below Hedge maze
       .byte Rm06-Rm00 ;$11 Outside yellow Castle -> $06 Hedge maze bottom
       .byte Rm1D-Rm00 ;$1C Above right corridor,right of catacombs -> $1D Under right corridor
       .byte RD6-RD0   ;$1D Under right corridor -> 6th set of differences
       .byte Rm06-Rm00 ;$1E Warren Robinett's room -> $06 Hedge maze bottom
 
East_Map_Tbl: ;room to the Right ;room#, description (from -> to)
    IF USE_TITLE_DISPLAY = 0
       .byte $00       ;$00 Number room -> $00 Number room
    ENDIF
       .byte Rm12-Rm00 ;$12 Inside yellow castle -> $12 Inside yellow castle
       .byte RD4-RD0   ;$1B inside black castle -> 4th set of differences
       .byte Rm14-Rm00 ;$13 Black maze right of entry -> $14 Black maze challise room
       .byte Rm15-Rm00 ;$14 Black maze challise room -> $15 Black maze dot's room
       .byte Rm16-Rm00 ;$15 Black maze dot's room -> $16 Black maze entry
       .byte Rm13-Rm00 ;$16 Black maze entry -> $13 Black maze right of entry
       .byte Rm18-Rm00 ;$17 Red maze above black key's room -> $18 Red maze above entry
       .byte Rm17-Rm00 ;$18 Red maze above entry -> $17 Red maze above black key's room
       .byte Rm1A-Rm00 ;$19 Red maze black key's room -> $1A Red maze entry
       .byte Rm19-Rm00 ;$1A Red maze entry -> $19 Red maze black key's room
       .byte Rm02-Rm00 ;$01 Below Hedge maze -> $02 Below yellow castle
       .byte Rm03-Rm00 ;$02 Below yellow castle -> $03 Above the catacombs
       .byte Rm01-Rm00 ;$03 Above the catacombs -> $01 Below Hedge maze
       .byte Rm05-Rm00 ;$04 Hedge maze below black castle -> $05 Hedge maze above entry
       .byte Rm06-Rm00 ;$05 Hedge maze above entry -> $06 Hedge maze bottom
       .byte Rm04-Rm00 ;$06 Hedge maze bottom -> $04 Hedge maze below black castle
       .byte Rm08-Rm00 ;$07 Hedge maze center -> $08 Hedge maze entry
       .byte Rm07-Rm00 ;$08 Hedge maze entry -> $07 Hedge maze center
       .byte Rm0A-Rm00 ;$09 Catacombs middle -> $0A Catacombs entry
       .byte Rm09-Rm00 ;$0A Catacombs entry -> $09 Catacombs middle
       .byte Rm0C-Rm00 ;$0B Catacombs side -> $0C Right corridor right of catacombs
       .byte Rm0D-Rm00 ;$0C Right corridor right of catacombs -> $0D Left cr below white castle
       .byte Rm0B-Rm00 ;$0D Left corridor below white Castle -> $0B Catacombs side
       .byte Rm10-Rm00 ;$0E Below left corridor -> $10 Outside black castle
       .byte Rm0F-Rm00 ;$0F Outside white Castle -> $0F Outside white castle
       .byte Rm1C-Rm00 ;$10 Outside black Castle -> $1C Above right corridor right of catacombs
       .byte Rm03-Rm00 ;$11 Outside yellow Castle -> $03 Above the catacombs
       .byte Rm07-Rm00 ;$1C Above right corridor right of catacombs -> $07 Hedge maze center
       .byte Rm01-Rm00 ;$1D Under right corridor -> $01 Below Hedge maze
       .byte Rm01-Rm00 ;$1E Warren Robinett's room -> $01 Below Hedge maze
 
South_Map_Tbl: ;room to the South ;room#, description (from -> to)
    IF USE_TITLE_DISPLAY = 0
       .byte $00       ;$00 Number room -> $00 Number room
    ENDIF
       .byte Rm12-Rm00 ;$12 Inside yellow castle -> $12 Inside yellow castle
       .byte RD4-RD0   ;$1B Inside black castle -> 4th set of differences
       .byte Rm15-Rm00 ;$13 Black maze right of entry -> $15 Black maze dot's room
       .byte Rm16-Rm00 ;$14 Black maze challise room -> $16 Black maze entry
       .byte Rm13-Rm00 ;$15 Black maze dot's room -> $13 Black maze right of entry
       .byte Rm1B-Rm00 ;$16 Black maze entry -> $1B Inside black castle
       .byte Rm19-Rm00 ;$17 Red maze above black key's room -> $19 Red maze black key's room
       .byte Rm1A-Rm00 ;$18 Red maze above entry -> $1A Red maze entry
       .byte Rm17-Rm00 ;$19 Red maze black key's room -> $17 Red maze above black key's room
       .byte Rm18-Rm00 ;$1A Red maze entry -> $18 Red maze above entry
       .byte RD1-RD0   ;$01 Below Hedge maze -> 1st set of differences
       .byte RD2-RD0   ;$02 Below yellow castle -> 2nd set of differences
       .byte RD3-RD0   ;$03 Above the catacombs -> 3rd set of differences
       .byte Rm07-Rm00 ;$04 Hedge maze below black castle -> $07 Hedge maze center
       .byte Rm08-Rm00 ;$05 Hedge maze above entry -> $08 Hedge maze entry
       .byte Rm03-Rm00 ;$06 Hedge maze bottom -> $03 Above the catacombs
       .byte Rm06-Rm00 ;$07 Hedge maze center -> $06 Hedge maze bottom
       .byte Rm01-Rm00 ;$08 Hedge maze entry -> $01 Below Hedge maze
       .byte Rm0B-Rm00 ;$09 Catacombs middle -> $0B Catacombs side
       .byte Rm09-Rm00 ;$0A Catacombs entry -> $09 Catacombs middle
       .byte Rm1C-Rm00 ;$0B Catacombs side -> $1C Above right corridor right of catacombs
       .byte Rm1D-Rm00 ;$0C Right corridor right of catacombs -> $1D Under right corridor
       .byte Rm0E-Rm00 ;$0D Left corridor below white Castle -> $0E Below left corridor
       .byte Rm0F-Rm00 ;$0E Below left corridor -> $0F Outside white Castle
       .byte Rm0D-Rm00 ;$0F Outside white Castle -> $0D Left corridor below white Castle
       .byte Rm04-Rm00 ;$10 Outside black Castle -> $04 Hedge maze below black castle
       .byte Rm02-Rm00 ;$11 Outside yellow Castle -> $02 Below yellow castle
       .byte RD5-RD0   ;$1C Above right corridor right of catacombs -> 5th set of differences
       .byte Rm10-Rm00 ;$1D Under right corridor -> $10 Outside black Castle
       .byte Rm06-Rm00 ;$1E Warren Robinett's room -> $06 Hedge maze bottom
 
West_Map_Tbl: ;room to the Left ;room#, description (from -> to)
    IF USE_TITLE_DISPLAY = 0
       .byte $00       ;$00 Number room -> $00 Number room
    ENDIF
       .byte Rm12-Rm00 ;$12 Inside yellow castle -> $12 Inside yellow castle
       .byte RD4-RD0   ;$1B inside black castle -> 4th set of differences
       .byte Rm16-Rm00 ;$13 Black maze right of entry -> $16 Black maze entry
       .byte Rm13-Rm00 ;$14 Black maze challise room -> $13 Black maze dot's room
       .byte Rm14-Rm00 ;$15 Black maze dot's room -> $14 Black maze challise room
       .byte Rm15-Rm00 ;$16 Black maze entry -> $15 Black maze dot's room
       .byte Rm18-Rm00 ;$17 Red maze above black key's room -> $18 Red maze above entry
       .byte Rm17-Rm00 ;$18 Red maze above entry -> $17 Red maze above black key's room
       .byte Rm1A-Rm00 ;$19 Red maze black key's room -> $1A Red maze entry
       .byte Rm19-Rm00 ;$1A Red maze entry -> $19 Red maze black key's room
       .byte Rm03-Rm00 ;$01 Below Hedge maze -> $03 Above the catacombs
       .byte Rm01-Rm00 ;$02 Below yellow castle -> $01 Below Hedge maze
       .byte Rm02-Rm00 ;$03 Above the catacombs -> $02 Below yellow castle
       .byte Rm06-Rm00 ;$04 Hedge maze below black castle -> $06 Hedge maze bottom
       .byte Rm04-Rm00 ;$05 Hedge maze above entry -> $04 Hedge maze below black castle
       .byte Rm05-Rm00 ;$06 Hedge maze bottom -> $05 Hedge maze above entry
       .byte Rm08-Rm00 ;$07 Hedge maze center -> $08 Hedge maze entry
       .byte Rm07-Rm00 ;$08 Hedge maze entry -> $07 Hedge maze center
       .byte Rm0A-Rm00 ;$09 Catacombs middle -> $0A Catacombs entry
       .byte Rm09-Rm00 ;$0A Catacombs entry -> $09 Catacombs middle
       .byte Rm0D-Rm00 ;$0B Catacombs side -> $0D Left corridor below white Castle
       .byte Rm0B-Rm00 ;$0C Right corridor right of catacombs -> $0B Catacombs side
       .byte Rm0C-Rm00 ;$0D Left corridor below white Castle -> $0C Right cr right of catacombs
       .byte Rm10-Rm00 ;$0E Below left corridor -> $10 Outside black Castle
       .byte Rm0F-Rm00 ;$0F Outside white Castle -> $0F Outside white Castle
       .byte Rm1C-Rm00 ;$10 Outside black Castle -> $1C Above right corridor right of catacombs
       .byte Rm01-Rm00 ;$11 Outside yellow Castle -> $01 Below Hedge maze
       .byte Rm08-Rm00 ;$1C Above right corridor right of catacombs -> $08
       .byte Rm03-Rm00 ;$1D Under right corridor -> $03 Above the catacombs
       .byte Rm03-Rm00 ;$1E Warren Robinett's room -> $03 Above the catacombs
 
  ELSE
 
RoomGFX_LSB_Tbl: ;LSB of gfx ;room#, description
Rm00:
    IF USE_TITLE_DISPLAY = 0
           .byte <Room00     ;$00 Number room
    ENDIF
Rm01:      .byte <Room01     ;$01 Below Hedge maze
Rm02:      .byte <Room02     ;$02 Below yellow castle
Rm03:      .byte <Room03     ;$03 Above the catacombs
Rm04:      .byte <Room04     ;$04 Hedge maze below black castle
Rm05:      .byte <Room05     ;$05 Hedge maze above entry
Rm06:      .byte <Room06     ;$06 Hedge maze bottom
Rm07:      .byte <Room07     ;$07 Hedge maze center
Rm08:      .byte <Room08     ;$08 Hedge maze entry
Rm09:      .byte <Room09     ;$09 Catacombs middle
Rm0A:      .byte <Room0A     ;$0A Catacombs entry
Rm0B:      .byte <Room0B     ;$0B Catacombs side
Rm0C:      .byte <Room0C     ;$0C Right corridor right of catacombs
Rm0D:      .byte <Room0D     ;$0D Left corridor below white Castle
Rm0E:      .byte <Room0E     ;$0E Below left corridor
Rm0F:      .byte <Room0F     ;$0F Outside white Castle
Rm10:      .byte <Room10     ;$10 Outside black Castle
Rm11:      .byte <Room11     ;$11 Outside yellow Castle
Rm12:      .byte <Room12     ;$12 Inside yellow castle
Rm13:      .byte <Room13     ;$13 Black maze right of entry
Rm14:      .byte <Room14     ;$14 Black maze challise room
Rm15:      .byte <Room15     ;$15 Black maze dot's room
Rm16:      .byte <Room16     ;$16 Black maze entry
Rm17:      .byte <Room17     ;$17 Red maze above black key's room
Rm18:      .byte <Room18     ;$18 Red maze above entry
Rm19:      .byte <Room19     ;$19 Red maze black key's room
Rm1A:      .byte <Room1A     ;$1A Red maze entry
Rm1B:      .byte <Room1B     ;$1B Just inside black castle
Rm1C:      .byte <Room1C     ;$1C Above right corridor right of catacombs
Rm1D:      .byte <Room1D     ;$1D Under right corridor
Rm1E:      .byte <Room1E     ;$1E Warren Robinett's room
 
 
RoomGFX_MSB_Tbl: ;MSB of gfx ;room#, description
;           Bit 5-7 ($20/$40/$80): bank number where room GFX exists
;           Bit 4   (+$10): False if surround object needed
    IF USE_TITLE_DISPLAY = 0
       .byte (>Room00)&$0F | BANK0            ;$00 Number room
    ENDIF
       .byte (>Room01)&$0F | BANK0            ;$01 Below Hedge maze
       .byte (>Room02)&$0F | BANK0            ;$02 Below yellow castle
       .byte (>Room03)&$0F | BANK0            ;$03 Above the catacombs
       .byte (>Room04)&$0F | BANK0            ;$04 Hedge maze below black castle
       .byte (>Room05)&$0F | BANK0            ;$05 Hedge maze above entry
       .byte (>Room06)&$0F | BANK0            ;$06 Hedge maze bottom
       .byte (>Room07)&$0F | BANK0            ;$07 Hedge maze center
       .byte (>Room08)&$0F | BANK0            ;$08 Hedge maze entry
       .byte (>Room09)&$0F | BANK0 | SURROUND ;$09 Catacombs middle
       .byte (>Room0A)&$0F | BANK0 | SURROUND ;$0A Catacombs entry
       .byte (>Room0B)&$0F | BANK0 | SURROUND ;$0B Catacombs side
       .byte (>Room0C)&$0F | BANK0            ;$0C Right corridor right of catacombs
       .byte (>Room0D)&$0F | BANK0            ;$0D Left corridor below white Castle
       .byte (>Room0E)&$0F | BANK0            ;$0E Below left corridor
       .byte (>Room0F)&$0F | BANK0            ;$0F Outside white Castle
       .byte (>Room10)&$0F | BANK0            ;$10 Outside black Castle
       .byte (>Room11)&$0F | BANK0            ;$11 Outside yellow Castle
       .byte (>Room12)&$0F | BANK0            ;$12 Inside yellow castle
       .byte (>Room13)&$0F | BANK0 | SURROUND ;$13 Black maze right of entry
       .byte (>Room14)&$0F | BANK0 | SURROUND ;$14 Black maze challise room
       .byte (>Room15)&$0F | BANK0 | SURROUND ;$15 Black maze dot's room
       .byte (>Room16)&$0F | BANK0 | SURROUND ;$16 Black maze entry
       .byte (>Room17)&$0F | BANK0            ;$17 Red maze above black key's room
       .byte (>Room18)&$0F | BANK0            ;$18 Red maze above entry
       .byte (>Room19)&$0F | BANK0            ;$19 Red maze black key's room
       .byte (>Room1A)&$0F | BANK0            ;$1A Red maze entry
       .byte (>Room1B)&$0F | BANK0            ;$1B Just inside black castle
       .byte (>Room1C)&$0F | BANK0            ;$1C Above right corridor right of catacombs
       .byte (>Room1D)&$0F | BANK0            ;$1D Under right corridor
       .byte (>Room1E)&$0F | BANK0            ;$1E Warren Robinett's room
 
 
;NOTE: the following table is not used for Multicolor mode (so walls are unable to flash there)
    IF MONOCOLOR
      IF PAL
Wall_Color_Tbl: ;playfield color ;room#, description...if an odd number, room is to Flash
       IF USE_TITLE_DISPLAY = 0
       .byte $A6     ;$00 Number room
       ENDIF
       .byte $38     ;$01 Below blue maze
       .byte $58     ;$02 Below yellow castle
       .byte $3A     ;$03 Above the catacombs
       .byte $D6     ;$04 Blue maze below black castle
       .byte $D6     ;$05 Blue maze above entry
       .byte $D6     ;$06 Blue maze bottom
       .byte $D6     ;$07 Blue maze center
       .byte $D6     ;$08 Blue maze entry
       .byte $08     ;$09 Catacombs middle
       .byte $08     ;$0A Catacombs entry
       .byte $08     ;$0B Catacombs side
       .byte $B8     ;$0C Right corridor right of catacombs
       .byte $78     ;$0D Left corridor below white Castle
       .byte $98     ;$0E Below left corridor
       .byte $0C     ;$0F Outside white Castle
       .byte $00     ;$10 Outside black Castle
       .byte $2C     ;$11 Outside yellow Castle
       .byte $2C     ;$12 Inside yellow castle
       .byte $08     ;$13 Black maze right of entry
       .byte $08     ;$14 Black maze challise room
       .byte $08     ;$15 Black maze dot's room
       .byte $08     ;$16 Black maze entry
       .byte $46     ;$17 Red maze above black key's room
       .byte $46     ;$18 Red maze above entry
       .byte $46     ;$19 Red maze black key's room
       .byte $46     ;$1A Red maze entry
       .byte $46     ;$1B Just inside black castle
       .byte $A6     ;$1C Above right corridor right of catacombs
       .byte $46     ;$1D Under right corridor
       .byte $A6     ;$1E Warren Robinett's room
      ELSE
Wall_Color_Tbl: ;playfield color ;room#, description...if an odd number, room is to Flash
       IF USE_TITLE_DISPLAY = 0
       .byte $66     ;$00 Number room
       ENDIF
       .byte $D8     ;$01 Below blue maze
       .byte $C8     ;$02 Below yellow castle
       .byte $E8     ;$03 Above the catacombs
       .byte $86     ;$04 Blue maze below black castle
       .byte $86     ;$05 Blue maze above entry
       .byte $86     ;$06 Blue maze bottom
       .byte $86     ;$07 Blue maze center
       .byte $86     ;$08 Blue maze entry
       .byte $08     ;$09 Catacombs middle
       .byte $08     ;$0A Catacombs entry
       .byte $08     ;$0B Catacombs side
       .byte $98     ;$0C Right corridor right of catacombs
       .byte $B8     ;$0D Left corridor below white Castle
       .byte $A8     ;$0E Below left corridor
       .byte $0C     ;$0F Outside white Castle
       .byte $00     ;$10 Outside black Castle
       .byte $1A     ;$11 Outside yellow Castle
       .byte $1A     ;$12 Inside yellow castle
       .byte $08     ;$13 Black maze right of entry
       .byte $08     ;$14 Black maze challise room
       .byte $08     ;$15 Black maze dot's room
       .byte $08     ;$16 Black maze entry
       .byte $36     ;$17 Red maze above black key's room
       .byte $36     ;$18 Red maze above entry
       .byte $36     ;$19 Red maze black key's room
       .byte $36     ;$1A Red maze entry
       .byte $36     ;$1B Just inside black castle
       .byte $66     ;$1C Above right corridor right of catacombs
       .byte $36     ;$1D Under right corridor
       .byte $66     ;$1E Warren Robinett's room
      ENDIF
    ENDIF
 
 
    IF USE_UNIQUE_BACKGROUND_COLORS
      IF PAL
Ground_Color_Tbl: ;if an odd number, background is to Flash
       IF USE_TITLE_DISPLAY = 0
       .byte $08     ;$00 Number room
       ENDIF
       .byte $08     ;$01 Below Hedge maze
       .byte $08     ;$02 Below yellow castle
       .byte $08     ;$03 Above the catacombs
       .byte $08     ;$04 Hedge maze below black castle
       .byte $08     ;$05 Hedge maze above entry
       .byte $08     ;$06 Hedge maze bottom
       .byte $08     ;$07 Hedge maze center
       .byte $08     ;$08 Hedge maze entry
       .byte $08     ;$09 Catacombs middle
       .byte $08     ;$0A Catacombs entry
       .byte $08     ;$0B Catacombs side
       .byte $08     ;$0C Right corridor right of catacombs
       .byte $08     ;$0D Left corridor below white Castle
       .byte $08     ;$0E Below left corridor
       .byte $08     ;$0F Outside white Castle
       .byte $08     ;$10 Outside black Castle
       .byte $08     ;$11 Outside yellow Castle
       .byte $08     ;$12 Inside yellow castle
       .byte $08     ;$13 Black maze right of entry
       .byte $08     ;$14 Black maze challise room
       .byte $08     ;$15 Black maze dot's room
       .byte $08     ;$16 Black maze entry
       .byte $08     ;$17 Red maze above black key's room
       .byte $08     ;$18 Red maze above entry
       .byte $08     ;$19 Red maze black key's room
       .byte $08     ;$1A Red maze entry
       .byte $08     ;$1B Just inside black castle
       .byte $08     ;$1C Above right corridor right of catacombs
       .byte $08     ;$1D Under right corridor
       .byte $08     ;$1E Warren Robinett's room
    ELSE
Ground_Color_Tbl: ;if an odd number, background is to Flash
       IF USE_TITLE_DISPLAY = 0
       .byte $08     ;$00 Number room
       ENDIF
       .byte $08     ;$01 Below Hedge maze
       .byte $08     ;$02 Below yellow castle
       .byte $08     ;$03 Above the catacombs
       .byte $08     ;$04 Hedge maze below black castle
       .byte $08     ;$05 Hedge maze above entry
       .byte $08     ;$06 Hedge maze bottom
       .byte $08     ;$07 Hedge maze center
       .byte $08     ;$08 Hedge maze entry
       .byte $08     ;$09 Catacombs middle
       .byte $08     ;$0A Catacombs entry
       .byte $08     ;$0B Catacombs side
       .byte $08     ;$0C Right corridor right of catacombs
       .byte $08     ;$0D Left corridor below white Castle
       .byte $08     ;$0E Below left corridor
       .byte $08     ;$0F Outside white Castle
       .byte $08     ;$10 Outside black Castle
       .byte $08     ;$11 Outside yellow Castle
       .byte $08     ;$12 Inside yellow castle
       .byte $08     ;$13 Black maze right of entry
       .byte $08     ;$14 Black maze challise room
       .byte $08     ;$15 Black maze dot's room
       .byte $08     ;$16 Black maze entry
       .byte $08     ;$17 Red maze above black key's room
       .byte $08     ;$18 Red maze above entry
       .byte $08     ;$19 Red maze black key's room
       .byte $08     ;$1A Red maze entry
       .byte $08     ;$1B Just inside black castle
       .byte $08     ;$1C Above right corridor right of catacombs
       .byte $08     ;$1D Under right corridor
       .byte $08     ;$1E Warren Robinett's room
      ENDIF
    ENDIF
 
North_Map_Tbl: ;room to the North ;room#, description (from -> to)
    IF USE_TITLE_DISPLAY = 0
       .byte $00       ;$00 Number room -> $00 Number room
    ENDIF
       .byte Rm08-Rm00 ;$01 Below Hedge maze -> $08 Hedge maze entry
       .byte Rm11-Rm00 ;$02 Below yellow castle -> $11 Outside yellow castle
       .byte Rm06-Rm00 ;$03 Above the catacombs -> $06 Hedge maze bottom
       .byte Rm10-Rm00 ;$04 Hedge maze below black castle -> $10 Outside black castle
       .byte Rm1D-Rm00 ;$05 Hedge maze above entry -> $1D Under right corridor
       .byte Rm07-Rm00 ;$06 Hedge maze bottom -> $07 Hedge maze center
       .byte Rm04-Rm00 ;$07 Hedge maze center -> $04 Hedge maze below black castle
       .byte Rm05-Rm00 ;$08 Hedge maze entry -> $05 Hedge maze above entry
       .byte Rm0A-Rm00 ;$09 Catacombs middle -> $0A Catacombs entry
       .byte Rm03-Rm00 ;$0A Catacombs entry -> $03 Above the catacombs
       .byte Rm09-Rm00 ;$0B Catacombs side -> $09 Catacombs middle
       .byte Rm1C-Rm00 ;$0C Right corridor right of catacombs -> $1C Above right corridor
       .byte Rm0F-Rm00 ;$0D Left corridor below white Castle -> $0F Outside white castle
       .byte Rm0D-Rm00 ;$0E Below left corridor -> $0D Left corridor below white castle
       .byte Rm0E-Rm00 ;$0F Outside white Castle -> $0E Below left corridor
       .byte Rm01-Rm00 ;$10 Outside black Castle -> $01 Below Hedge maze
       .byte Rm06-Rm00 ;$11 Outside yellow Castle -> $06 Hedge maze bottom
       .byte Rm12-Rm00 ;$12 Inside yellow castle -> $12 Inside yellow castle
       .byte Rm15-Rm00 ;$13 Black maze right of entry -> $15 Black maze dot's room
       .byte Rm16-Rm00 ;$14 Black maze challise room -> $16 Black maze entry
       .byte Rm13-Rm00 ;$15 Black maze dot's room -> $13 Black maze right of entry
       .byte Rm14-Rm00 ;$16 Black maze entry -> $14 Black maze challise room
       .byte Rm19-Rm00 ;$17 Red maze above black key's room -> $19 Red maze black key's room
       .byte Rm1A-Rm00 ;$18 Red maze above entry -> $1A Red maze entry
       .byte Rm17-Rm00 ;$19 Red maze black key's room -> $17 Red maze above black key's room
       .byte Rm18-Rm00 ;$1A Red maze entry -> $18 Red maze above entry
       .byte RD4-RD0   ;$1B inside black castle -> 4th set of differences
       .byte Rm1D-Rm00 ;$1C Above right corridor,right of catacombs -> $1D Under right corridor
       .byte RD6-RD0   ;$1D Under right corridor -> 6th set of differences
       .byte Rm06-Rm00 ;$1E Warren Robinett's room -> $06 Hedge maze bottom
 
East_Map_Tbl: ;room to the Right ;room#, description (from -> to)
    IF USE_TITLE_DISPLAY = 0
       .byte $00       ;$00 Number room -> $00 Number room
    ENDIF
       .byte Rm02-Rm00 ;$01 Below Hedge maze -> $02 Below yellow castle
       .byte Rm03-Rm00 ;$02 Below yellow castle -> $03 Above the catacombs
       .byte Rm01-Rm00 ;$03 Above the catacombs -> $01 Below Hedge maze
       .byte Rm05-Rm00 ;$04 Hedge maze below black castle -> $05 Hedge maze above entry
       .byte Rm06-Rm00 ;$05 Hedge maze above entry -> $06 Hedge maze bottom
       .byte Rm04-Rm00 ;$06 Hedge maze bottom -> $04 Hedge maze below black castle
       .byte Rm08-Rm00 ;$07 Hedge maze center -> $08 Hedge maze entry
       .byte Rm07-Rm00 ;$08 Hedge maze entry -> $07 Hedge maze center
       .byte Rm0A-Rm00 ;$09 Catacombs middle -> $0A Catacombs entry
       .byte Rm09-Rm00 ;$0A Catacombs entry -> $09 Catacombs middle
       .byte Rm0C-Rm00 ;$0B Catacombs side -> $0C Right corridor right of catacombs
       .byte Rm0D-Rm00 ;$0C Right corridor right of catacombs -> $0D Left cr below white castle
       .byte Rm0B-Rm00 ;$0D Left corridor below white Castle -> $0B Catacombs side
       .byte Rm10-Rm00 ;$0E Below left corridor -> $10 Outside black castle
       .byte Rm0F-Rm00 ;$0F Outside white Castle -> $0F Outside white castle
       .byte Rm1C-Rm00 ;$10 Outside black Castle -> $1C Above right corridor right of catacombs
       .byte Rm03-Rm00 ;$11 Outside yellow Castle -> $03 Above the catacombs
       .byte Rm12-Rm00 ;$12 Inside yellow castle -> $12 Inside yellow castle
       .byte Rm14-Rm00 ;$13 Black maze right of entry -> $14 Black maze challise room
       .byte Rm15-Rm00 ;$14 Black maze challise room -> $15 Black maze dot's room
       .byte Rm16-Rm00 ;$15 Black maze dot's room -> $16 Black maze entry
       .byte Rm13-Rm00 ;$16 Black maze entry -> $13 Black maze right of entry
       .byte Rm18-Rm00 ;$17 Red maze above black key's room -> $18 Red maze above entry
       .byte Rm17-Rm00 ;$18 Red maze above entry -> $17 Red maze above black key's room
       .byte Rm1A-Rm00 ;$19 Red maze black key's room -> $1A Red maze entry
       .byte Rm19-Rm00 ;$1A Red maze entry -> $19 Red maze black key's room
       .byte RD4-RD0   ;$1B inside black castle -> 4th set of differences
       .byte Rm07-Rm00 ;$1C Above right corridor right of catacombs -> $07 Hedge maze center
       .byte Rm01-Rm00 ;$1D Under right corridor -> $01 Below Hedge maze
       .byte Rm01-Rm00 ;$1E Warren Robinett's room -> $01 Below Hedge maze
 
South_Map_Tbl: ;room to the South ;room#, description (from -> to)
    IF USE_TITLE_DISPLAY = 0
       .byte $00       ;$00 Number room -> $00 Number room
    ENDIF
       .byte RD1-RD0   ;$01 Below Hedge maze -> 1st set of differences
       .byte RD2-RD0   ;$02 Below yellow castle -> 2nd set of differences
       .byte RD3-RD0   ;$03 Above the catacombs -> 3rd set of differences
       .byte Rm07-Rm00 ;$04 Hedge maze below black castle -> $07 Hedge maze center
       .byte Rm08-Rm00 ;$05 Hedge maze above entry -> $08 Hedge maze entry
       .byte Rm03-Rm00 ;$06 Hedge maze bottom -> $03 Above the catacombs
       .byte Rm06-Rm00 ;$07 Hedge maze center -> $06 Hedge maze bottom
       .byte Rm01-Rm00 ;$08 Hedge maze entry -> $01 Below Hedge maze
       .byte Rm0B-Rm00 ;$09 Catacombs middle -> $0B Catacombs side
       .byte Rm09-Rm00 ;$0A Catacombs entry -> $09 Catacombs middle
       .byte Rm1C-Rm00 ;$0B Catacombs side -> $1C Above right corridor right of catacombs
       .byte Rm1D-Rm00 ;$0C Right corridor right of catacombs -> $1D Under right corridor
       .byte Rm0E-Rm00 ;$0D Left corridor below white Castle -> $0E Below left corridor
       .byte Rm0F-Rm00 ;$0E Below left corridor -> $0F Outside white Castle
       .byte Rm0D-Rm00 ;$0F Outside white Castle -> $0D Left corridor below white Castle
       .byte Rm04-Rm00 ;$10 Outside black Castle -> $04 Hedge maze below black castle
       .byte Rm02-Rm00 ;$11 Outside yellow Castle -> $02 Below yellow castle
       .byte Rm12-Rm00 ;$12 Inside yellow castle -> $12 Inside yellow castle
       .byte Rm15-Rm00 ;$13 Black maze right of entry -> $15 Black maze dot's room
       .byte Rm16-Rm00 ;$14 Black maze challise room -> $16 Black maze entry
       .byte Rm13-Rm00 ;$15 Black maze dot's room -> $13 Black maze right of entry
       .byte Rm1B-Rm00 ;$16 Black maze entry -> $1B Inside black castle
       .byte Rm19-Rm00 ;$17 Red maze above black key's room -> $19 Red maze black key's room
       .byte Rm1A-Rm00 ;$18 Red maze above entry -> $1A Red maze entry
       .byte Rm17-Rm00 ;$19 Red maze black key's room -> $17 Red maze above black key's room
       .byte Rm18-Rm00 ;$1A Red maze entry -> $18 Red maze above entry
       .byte RD4-RD0   ;$1B Inside black castle -> 4th set of differences
       .byte RD5-RD0   ;$1C Above right corridor right of catacombs -> 5th set of differences
       .byte Rm10-Rm00 ;$1D Under right corridor -> $10 Outside black Castle
       .byte Rm06-Rm00 ;$1E Warren Robinett's room -> $06 Hedge maze bottom
 
West_Map_Tbl: ;room to the Left ;room#, description (from -> to)
    IF USE_TITLE_DISPLAY = 0
       .byte $00       ;$00 Number room -> $00 Number room
    ENDIF
       .byte Rm03-Rm00 ;$01 Below Hedge maze -> $03 Above the catacombs
       .byte Rm01-Rm00 ;$02 Below yellow castle -> $01 Below Hedge maze
       .byte Rm02-Rm00 ;$03 Above the catacombs -> $02 Below yellow castle
       .byte Rm06-Rm00 ;$04 Hedge maze below black castle -> $06 Hedge maze bottom
       .byte Rm04-Rm00 ;$05 Hedge maze above entry -> $04 Hedge maze below black castle
       .byte Rm05-Rm00 ;$06 Hedge maze bottom -> $05 Hedge maze above entry
       .byte Rm08-Rm00 ;$07 Hedge maze center -> $08 Hedge maze entry
       .byte Rm07-Rm00 ;$08 Hedge maze entry -> $07 Hedge maze center
       .byte Rm0A-Rm00 ;$09 Catacombs middle -> $0A Catacombs entry
       .byte Rm09-Rm00 ;$0A Catacombs entry -> $09 Catacombs middle
       .byte Rm0D-Rm00 ;$0B Catacombs side -> $0D Left corridor below white Castle
       .byte Rm0B-Rm00 ;$0C Right corridor right of catacombs -> $0B Catacombs side
       .byte Rm0C-Rm00 ;$0D Left corridor below white Castle -> $0C Right cr right of catacombs
       .byte Rm10-Rm00 ;$0E Below left corridor -> $10 Outside black Castle
       .byte Rm0F-Rm00 ;$0F Outside white Castle -> $0F Outside white Castle
       .byte Rm1C-Rm00 ;$10 Outside black Castle -> $1C Above right corridor right of catacombs
       .byte Rm01-Rm00 ;$11 Outside yellow Castle -> $01 Below Hedge maze
       .byte Rm12-Rm00 ;$12 Inside yellow castle -> $12 Inside yellow castle
       .byte Rm16-Rm00 ;$13 Black maze right of entry -> $16 Black maze entry
       .byte Rm13-Rm00 ;$14 Black maze challise room -> $13 Black maze dot's room
       .byte Rm14-Rm00 ;$15 Black maze dot's room -> $14 Black maze challise room
       .byte Rm15-Rm00 ;$16 Black maze entry -> $15 Black maze dot's room
       .byte Rm18-Rm00 ;$17 Red maze above black key's room -> $18 Red maze above entry
       .byte Rm17-Rm00 ;$18 Red maze above entry -> $17 Red maze above black key's room
       .byte Rm1A-Rm00 ;$19 Red maze black key's room -> $1A Red maze entry
       .byte Rm19-Rm00 ;$1A Red maze entry -> $19 Red maze black key's room
       .byte RD4-RD0   ;$1B inside black castle -> 4th set of differences
       .byte Rm08-Rm00 ;$1C Above right corridor right of catacombs -> $08
       .byte Rm03-Rm00 ;$1D Under right corridor -> $03 Above the catacombs
       .byte Rm03-Rm00 ;$1E Warren Robinett's room -> $03 Above the catacombs
  ENDIF
 
 
 
 
  IF BANKS = 0
       ORG  $2FF8,0
       RORG $FFF8
       .byte "3911"
  ENDIF
 
  IF BANKS = 1
       ORG  $4FF6,0
       RORG $FFF6
       .byte "3/9/11"
  ENDIF
 
  IF BANKS = 2
       ORG  $8FF4,0
       RORG $FFF4
       .byte "3/9/2011"
  ENDIF
       .word START ;cold start vector
       .word START ;interrupt vector
 

 

Edited by keithbk
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...