; Source of "Fawn Dungeon" (AKA: D&D For Bally) By Barry McCleave
; A game for the Bally / Astrocade Created 1981 Source-Version 2.0
; Re-typed and matched to binary by Adam Trionfo in March 2010.
; Additional work by Richard C. Degler
;
; The source code for this game was originally in 8080 machine
; language.  It was early and it did NOT create a binary that ran
; correctly.  The code has been updated to Z80 ML for use with the
; Bally / Astrocade.
;
; The code matches a usable binary that was recovered from an EPROM that
; was part of the Bob Fabris collection.  This is NOT a complete game,
; but it does allow the player to roam around a dungeon using the same
; Cowboy graphic that is found in the on-board ROM.
;
; Notes:
; What is unusual about the version that works is that instead of the
; source code being shifted around, there are NOPS and jumps inserted
; into the code that lead to previously unused areas of the ROM.  This
; in itself isn't strange at all.  This is the way that hacks are made.
; Why would someone need to do this if they have the source code?  This
; leads me to two conclusions:
;
; 1) The original author lost the source code, or no longer had access
;    to the computer that ran the assembler, so he had to make the
;    changes without altering the code.
;
; 2) Someone other than the original author of "Fawn Dungeon" made the
;    changes that were needed to make it work.  The source code that I
;    typed in DOES have some handwritten changes that were incorporated
;    into the final version.  Whether or not these changes were done
;    later, after the print-out was sent to Bob Fabris, or before Bob
;    received the printout is not known.
;

; Version History
; ---------------
; Version 2.0 - March 21, 2010 (By Richard C. Degler)
;    - Replaced ORGs with Labels.
;    - Added more HVGLIB.H information.
;    - Replaced all RST $38s with more comments.
;    - Added pattern comments for GunFighter.
;    - Mixed case comments are new, a LOT of them come straight
;      from the BIOS. 
;    - Changed remaining decimal to 2- or 4-digit hex
;      for readability.
;    - Notes:
;         - The new labels could use more description. 
;         - Identify the ReSTart #1-4.
;         - Identiy how the Royal Dungeon is laid out.
;         - Can now move new stubs (from working ROM) inline since
;           there is no need to match ROM anymore!
;         - All the absolute addresses (in the comments) can all
;           come out, just kept them in case things didn't line up.
;         - I appears that the JumP to L27A0: looks like it should
;           have been to L27A2: 
;
; Version 1.0 - March 20, 2010
;    - Changed to Z80 machine language and output matches EXACTLY
;      with binary that works correctly.
;    - Although this version DOES match 100% with the working ROM
;      image, it does so at the expense of not using labels for
;      the new areas that were added.  Those areas are HARD
;      CODED.  If the source code is added to, without adding
;      labels, then the binary will not work correctly.
;
; Version .01 - March 19, 2010
;    - Same as original 8080 Version that DOES NOT work.
;
; This code can be assembled into a usable binary using the ZMac
; assembler.  Here is a sample of the command line required:
;
;     zmac -i -m -o fawn.bin -x fawn.lst fawn.asm
;

        NOLIST

        INCLUDE "HVGLIB.H"      ; HOME VIDEO GAME LIBRARY

; some defines [STOLEN FROM GUNFIGHTER]
LCACX   EQU     $40 + $56       ; LEFT CACTUS X = 64 + 86 ??
TLINE   EQU     $05             ; TOP LINE OF GUNSPACE = 5 ??
BLINE   EQU     $5C - $06       ; BOTTOM LINE OF GUNSPACE = 92 - 6 ??

BULVSZ  EQU     $12 + 5         ; BULLET VECTOR SIZE = 18 + 5 ??

LFRLIN  EQU     $64 * 2         ; LOW PRIORITY FOREGROUND LINE = 200

NEXT    EQU     -1              ; NEXT LINE FOR QUEUES negative offset
  ;  extra BYTES in Vector Block
VBARM   EQU     $0F             ; VBOAH + 1 (offset) ARM STATE
VBOARM  EQU     $10             ; VBARM + 1 (offset) LAST ARM PATTERN WRITTEN
VBLEGT  EQU     $11             ; VBOARM + 1 (offset) LEG TIMER
VBLEG   EQU     $12             ; VBLEGT + 1 (offset) LEG LINK
VBCOMP  EQU     $13             ; VBLEG + 1 (offset) TIMER FOR COMPUTER CONTROL ?? not used !!

  ;  extra BITS in Vector Block Status byte
VBSCHG  EQU     +3              ; CHANGE STATUS BIT
VBSNOM  EQU     +4              ; NOT MOVING STATUS

  ; *************
  ; * ram cells *
  ; *************

SCR     EQU     NORMEM          ; aka 16384 ($4000)
;
STACK   EQU     $4F06           ; top of user STACK
;
WRITQ   EQU     $4F12           ; (word) WRITe Queue header [new equate]
VECQ    EQU     $4F15           ; (14 bytes) VECtor Q header [new]
;
RCOWB   EQU     $4F61           ; RIGHT COWBOY Vector Block [new]
;
STR     EQU     $4F8F           ; (byte) STRength [first of 6 traits:]
INT     EQU     $4F90           ; STR+1 (byte) INTelligence
WIS     EQU     $4F91           ; STR+2 (byte) WISdom
CON     EQU     $4F92           ; STR+3 (byte) CONstitution
DEX     EQU     $4F93           ; STR+4 (byte) DEXterity
CHA     EQU     $4F94           ; STR+5 (byte) CHArisma
;
TYP     EQU     $4F95           ; STR+6 (byte) weapon TYPe
; ammo1: [SWoRD, ARROw, DAGgeR, LTNG, MACE, HOLD, DAGgeR, HIDE]
; ammo2: [RUN, TAKE] common weapons
RACE    EQU     $4F96           ; STR+7 (byte) RACE
; races: [HUMan, ELF, HAFling, DWArf]
NUMWP   EQU     $4F97           ; STR+8 (byte) NUMber of WeaPon
; ?? type: [FI___AC2, MU__AC10, CL___AC3, TH___AC6] note: '_'s are SPACEs
;
ROOM    EQU     $4F98           ; STR+9 (byte) current ROOM
DOOR    EQU     $4F99           ; STR+10 (byte) DOOR position
WALLS   EQU     $4F9A           ; STR+11 (byte) WALLS flags
RELX    EQU     $4F9B           ; STR+12 (byte) RELative X
RELY    EQU     $4F9C           ; STR+13 (byte) RELative Y
RGLFCO  EQU     $4F9D           ; STR+14 (word) RGLFCO?? [not used ??]
WPNOW   EQU     $4F9F           ; STR+16 (byte) current WeaPon NOW
;
ENDSCR  EQU     $4FF4           ; ENDing SCoRe to play to
;

        LIST

        ORG     FIRSTC          ; aka 8192 ($2000)

        DB      $55             ; sentinal for Menu Start
        DW      MENUST          ; ... Next = $0218
        DW      FAWN            ; ... Text "FAWN DUNGEON"
        DW      BEGIN           ; ... Start

RST8:   CALL    NXTLN

RST10:  JP      CHR3

RST18:  JP      LFNUM1

RST20:  JP      NUM2

BEGIN:
        SYSSUK  GETPAR          ; UPI GET game PARameter from user
        DW      NUMHIT          ; ... Prompt Address "NUMBER OF HITS"
        DB      $82             ; ... 2 DIGITS with zero SUPPRESSION
        DW      ENDSCR          ; ... Parameter Address = 20468 ($4FF4)
        ;
        LD      SP,STACK
        SYSTEM  INTPC           ; UPI INTerPret with Context create
        ;
        DO      COLSET          ; UPI COLors SET GRN,WH,CY,MA,GRA,FL,RD,BLU
        DW      COLORS          ; ... Table Address = 9734 ($2606)
        ;
        DO      FILL            ; UPI FILL memory with data
        DW      STACK           ; ... Memory Address = 20230 ($4F06)
        DW      $00D6           ; ... Byte Count = 214 (STACK-STACK+$D6)
        DB      $00             ; ... Data = 0'S
        ;
        DO      SETOUT          ; UPI SET some OUTput ports
        DB      $B8             ; ... VERT. BLANKING * 2 = 184
        DB      $14             ; ... HORIZ. CENTER / 4 = 20, BC = 0
        DB      $08             ; ... INMODE = 8 light pen DISABLE
        ;
        DO      MOVE            ; UPI MOVE block transfer
        DW      CT5             ; ... Destination Address = 20442 ($4FDA)
        DW      $000C           ; ... Byte Count = 12
        DW      SINNIT          ; ... Source Address = 9287 ($2447)
        ;
        DONT    XINTC           ; UPI eXit INTerpreter with Context
        ;
        LD      HL,STR          ; BEGIN WITH STRENGTH
        LD      B,$06           ; 6 ROLL-UPS
; LOOP BEGIN
ROLOOP: SYSSUK  RANGED          ; UPI RANGED random number
        DB      $00             ; ... no Cutoff = 8 BITS
        ;
        LD      (ROOM),A        ; INITIAL ROOM
        AND     $0F             ; 0-15
        ADD     A,$03           ; 3-18
        CP      $0A
        JR      C,LSTH10        ; LESS THAN 10?
        SBC     A,$0A
        OR      $10
LSTH10: LD      (HL),A          ; BCD NO.->ATTRIBUTE
        INC     HL              ; NEXT ATTR.
        DJNZ    ROLOOP          ; FINISHED?
        SYSSUK  RANGED          ; UPI RANGED random number ROLL CHA. TYPE
        DB      $04             ; ... 0=FIGHTER, 1=MU, 2=CLERIC, 3=THIEF
        ;
        LD      (HL),A          ; SAVE IN CHAR.TYPE
        LD      HL,STR          ; MODIFY PRIME REQUISITE
        OR      A
        JR      Z,ENMOD
        INC     HL              ; INTELLIGENCE
        DEC     A
        JR      Z,ENMOD
        INC     HL              ; WISDOM
        DEC     A
        JR      Z,ENMOD
        INC     HL              ; BYPASS CON
        INC     HL              ; DEXTERITY
ENMOD:  LD      (HL),$18        ; MODIFY PRIME
        SYSSUK  RANGED          ; UPI RANGED random number for RACE
        DB      $04             ; ... 0=HUMAN, 1=ELF, 2=HALFLING, 3=DWARF
        LD      (RACE),A
        LD      A,$81           ; INITIALIZE ENTRY DOOR
        LD      (RELX),A        ; RELATIVE X POS. IN DOOR
        LD      A,$31
        LD      (RELY),A        ; REL. Y IN DOOR
        LD      (WPNOW),A
        NOP
STRND:  DI                      ; NEW ROOM
        SYSSUK  FILL            ; UPI FILL SCReen memory with data
        DW      SCR             ; ... Memory Address = 16384 ($4000)
        DW      $0E88           ; ... Byte Count = 3720 (to $4E88)
        DB      $00             ; ... Data = 0'S
        ;
        JP      L26F0           ; JUMP TO NEW SECTION OF CODE FROM EPROM

L2084:
        LD      A,(RACE)
        LD      H,A
        ADD     A,H
        ADD     A,H
        LD      H,$00           ; GET RACE IN ASCII
        LD      L,A
        ADD     HL,DE           ; DEPTH + BASE ADDRESS
        LD      DE,$0000        ; 0->D->E
        CALL    CHR3            ; DISP.3 CHAR.
        LD      E,$20           ; X POS. ON SCREEN
        LD      HL,WEAP         ; WEAPON TYPES
        LD      B,$04
        CALL    CHAR
        LD      HL,TRAITS       ; DISPLAY STRENGTH
        RST     $08             ; User ReStarT #1 of 6
        PUSH    HL
        LD      HL,STR
        RST     $20             ; User ReStarT #4 of 6
        POP     HL              ; DISPLAY INTELLIGENCE
        RST     $10             ; User ReStarT #2 of 6
        PUSH    HL
        LD      HL,INT
        RST     $20             ; User ReStarT #4 of 6
        POP     HL              ; WISDOM
        RST     $08             ; User ReStarT #1 of 6
        PUSH    HL
        LD      HL,WIS
        RST     $20             ; User ReStarT #4 of 6
        POP     HL              ; CONSTITUTION
        RST     $10             ; User ReStarT #2 of 6
        PUSH    HL
        LD      HL,CON
        RST     $20             ; User ReStarT #4 of 6
        POP     HL              ; DEXTERITY
        RST     $08             ; User ReStarT #1 of 6
        PUSH    HL
        LD      HL,DEX
        RST     $20             ; User ReStarT #4 of 6
        POP     HL              ; CHARISMA
        RST     $10             ; User ReStarT #2 of 6
        LD      HL,CHA
        RST     $20             ; User ReStarT #4 of 6
        CALL    NXTLN           ; DISPLAY CHAR. TYPE
        LD      A,(TYP)
        RLA
        RLA
        RLA
        LD      L,A
        LD      H,$00
        PUSH    HL              ; SAVE TYPES TIMES 8
        LD      BC,TYPE
        ADD     HL,BC           ; ADDRESS OF ASCII
        LD      B,$08
        CALL    CHAR
; HL HAS TYPE 8
; DISPLAY CHAR. WEAPONS
        POP     HL
        LD      BC,AMMO1
        ADD     HL,BC           ; DEPTH TO WEAPONS+BASE
        PUSH    HL
        LD      A,$01
        LD      HL,NUMWP
        LD      (HL),A
        RST     $18             ; User ReStarT #3 of 6
        POP     HL              ; WEAPON 1
        LD      B,$04
        CALL    CHAR
        PUSH    HL
        LD      HL,NUMWP
        INC     (HL)
        CALL    ONEBCD          ; WEAPON 2
        POP     HL
        LD      B,$04
        CALL    CHAR
        LD      HL,NUMWP        ; WEAPON 3
        INC     (HL)
        RST     $18             ; User ReStarT #3 of 6
        LD      HL,AMMO2        ; COMMON WEAPONS
        LD      B,$04
        CALL    CHAR
        PUSH    HL
        LD      HL,NUMWP        ; WEAPON 4
        INC     (HL)
        CALL    ONEBCD
        POP     HL
        LD      B,$04
        CALL    CHAR
; NUMBER OF HITS DISPLAY
        CALL    NXTLN
        LD      B,$04
        LD      HL,NUMHIT + $07
        CALL    CHAR
        LD      E,$30
        LD      HL,ENDSCR
        RST     $20             ; User ReStarT #4 of 6
; INSTALL ANY WALLS
        JP      L2710           ; JUMP TO NEW CODE FROM EPROM

L212F:
        LD      C,A
        LD      HL,DOORTB       ; GET A NIBBLE
        SYSTEM  INDEXN          ; UPI INDEX Nibble by C
        ;
        LD      (DOOR),A
        BIT     3,A
        JR      NZ,TSTLFT
BOTTOM: PUSH    AF
        SYSSUK  RECTAN          ; UPI paint a RECTANgle
        DB      $50             ; ... X = 80
        DB      $57             ; ... Y = 87
        DB      $50             ; ... Width = 80
        DB      $05             ; ... Height = 5
        DB      $AA             ; ... Color = 170 for COLOR 2
        ;
        POP     AF
TSTLFT: BIT     2,A
        JR      NZ,TSTTOP
LEFT:   PUSH    AF
        SYSSUK  RECTAN          ; UPI paint a RECTANgle
        DB      $50             ; ... X = 80
        DB      $00             ; ... Y = 0
        DB      $05             ; ... Width = 5
        DB      $5D             ; ... Height = 93
        DB      $AA             ; ... Color = 170
        ;
        POP     AF
TSTTOP: BIT     1,A
        JR      NZ,TSTRGT
TOP:    PUSH    AF
        SYSSUK  RECTAN          ; UPI paint a RECTANgle
        DB      $50             ; ... X = 80
        DB      $00             ; ... Y = 0
        DB      $50             ; ... Width = 80
        DB      $05             ; ... Height = 5
        DB      $AA             ; ... Color = 170
        ;
        POP     AF
TSTRGT: BIT     0,A
        JR      NZ,TSTFIN
RIGHT:  SYSSUK  RECTAN          ; UPI paint a RECTANgle
        DB      $9A             ; ... X = 154
        DB      $00             ; ... Y = 0
        DB      $05             ; ... Width = 5
        DB      $5D             ; ... Height = 93
        DB      $AA             ; ... Color = 170
        ;
TSTFIN: LD      A,$4F
        LD      (WRITQ+2),A     ; WRITE QUEUE HEADER + 2
        LD      (VECQ+2),A      ; WRITE VECTOR HEADER + 2 [$4F17]
        LD      HL,VECQ         ; VECT
        CALL    ENTRRM          ; COWBOY ENTER
  ; fire up interrupts (BALLY standard IM 2 is already done in MENU)
        LD      A,INTTBL SHR 8  ; HIGHER ORDER INTERRUPT VECTOR
        LD      I,A             ; LDIA
        LD      A,LFRVEC AND 0FFH ; LOWER ORDER INTERRUPT VECTOR
        OUT     (INFBK),A
        SYSSUK  PAWS            ; UPI PAUSE WHILE COWBOY WALKS OUT
        DB      $0A             ; ... Interrupts = 10 for 1.67 SEC.
        ;
; MAIN LOOP
LOOP:   SYSTEM  INTPC           ; UPI INTerPret with Context create
        ;
        DO      SENTRY          ; UPI SENse TRansition ENABLE ALL KEYS
        DW      ALKEYS          ; ... Keymask Address = 532 ($0214)
        ;
        DO      DOIT            ; UPI DOIT table, branch to translation handler
        DW      DOITAB          ; ... Table Address = 8852 ($2294)
        ;
        DONT    XINTC           ; UPI eXit INTerpreter with Context
        ;
; CHECK FOR WALLS
        LD      IX,RCOWB        ; Vector Block
        BIT     VBCLAT,(IX+VBXCHK) ; CHECK LIMITs OBTAINED
        JP      NZ,BONK
        BIT     VBCLAT,(IX+VBYCHK)
        JP      Z,LOOP
; HIT A WALL OR DOOR; WHICH ONE?
; BONK:   RES     4,(IX+VBYCHK)   ; [no bit 4 to reset ??]
;         LD      IX,RCOWB        ; Vector Block again ??
BONK:   RES     VBCLAT,(IX+VBXCHK) ; clear attained bits
        RES     VBCLAT,(IX+VBYCHK)
        LD      E,(IX+VBXH)     ; X-POS
        LD      D,(IX+VBYH)     ; Y-POS
        LD      A,(DOOR)        ; DOOR NIBBLE
        LD      C,A
        LD      A,$59           ; LEFT WALL?
        CP      E
        JR      NZ,NLFTWL
        BIT     2,C
        JP      Z,LOOP          ; HIT WALL
        LD      A,(ROOM)        ; NEXT ROOM
        INC     A
        LD      (ROOM),A
        LD      E,$81           ; 129
STRNPS: DI
        LD      HL,RELX
        LD      (HL),E
        INC     HL              ; RELY
        LD      (HL),D
        JP      STRND

NLFTWL:
        LD      A,$85           ; 133
        CP      E
        JR      NZ,NRGWL
        BIT     0,C
        JP      Z,LOOP
        LD      A,(ROOM)
        DEC     A
        LD      (ROOM),A
        LD      E,$5C           ; 92
        JP      STRNPS

; NRGWL:  XOR     A
;         CP      D
;         JR      NZ,NTPWL
NRGWL:
        JP      KLUDGE1

        DB      $17             ; THIS BYTE IS SKIPPED BY JUMP
        BIT     1,C
        JP      Z,LOOP
        LD      A,(ROOM)
        CP      $F0
        JP      Z,ENDGAM
        ADD     A,$10
        LD      (ROOM),A
        LD      D,$3E           ; 62
        JP      STRNPS

NTPWL:
        LD      A,$42           ; 66
        CP      D
        JR      NZ,LOOP
        BIT     3,C
        JP      Z,LOOP
        LD      A,(ROOM)
        SUB     $10
        LD      (ROOM),A
        LD      D,$09
        JP      STRNPS

; END OF GAME
ENDGAM:
        SYSTEM  QUIT            ; UPI QUIT cassette execution
        ;
; SUBROUTINE FOR NEW ROOM ENTRY
ENTRRM:
        LD      A,(RELX)
        CP      $81             ; 129
        LD      IX,RCOWB        ; RIGHT COWBOY Vector Block
        LD      (IX+VBMR),$10   ; OR & FLOP
        JR      Z,RGTONC
        LD      (IX+VBMR),$10   ; OR
RGTONC: LD      (IX+VBSTAT),$80 ; ACTIVATE VECTOR STATUS
        LD      (IX+VBXCHK),$01
        LD      (IX+VBYCHK),$01 ; X,Y CHECKS MASKS
        LD      (IX+VBARM),$06  ; [SET ARM STRAIGHT]
        LD      (IX+VBLEG),LEG0 AND $FF  ; $B0 ??
        JP      L27A0           ; NEW FROM EPROM - WAS, LD  A,(RELX) [should be to L27A2 ??]

L2241:
        LD      (IX+VBXH),A     ; X POS. HIGH
        LD      A,(RELY)
        LD      (IX+VBYH),A     ; Y POS. HIGH
        LD      A,(RELX)
        CP      $81             ; 129
        JP      NZ,L2797
        LD      (IX+VBDXL),$CE  ; 206 DELX LOWER
        JP      L2790

        CALL    L2620
        NOP
NXPSB1: LD      A,(RELY)
        CP      $09
        JR      NZ,NXPSB2
        LD      (IX+VBDYL),$CE  ; DELY = -50 LOWER
        LD      (IX+VBDYH),$FF
NXPSB2: CP      $3E             ; 62
        JR      Z,NXPSB3
        LD      (IX+VBDYL),$32  ; DELY LOWER = 50
        LD      (IX+VBDYH),$00  ; DELY UPPER
NXPSB3: JP      ADDTQ           ; ADDTQ

; SUBROUTINE TO ADVANCE LINE LF
NXTLN:
        LD      E,$00
        LD      A,$08
        ADD     A,D
        LD      D,A
        RET

; SUBROUTINE TO DISPLAY B CHARACTERS
; D REG. Y-COORDINATE
; E REG. X-COORDINATE
; HL POINTS TO CHAR BUFFER
; C OPTIONS BYTE
CHR3:
        LD      B,$03
CHAR:   LD      C,$04
LOOP3:  LD      A,(HL)
        INC     HL              ; H+1
        SYSTEM  CHRDIS          ; UPI CHaRacter DISplay
        ;
        DJNZ    LOOP3
        RET

; SUBROUTINE TO DISPLAY BCD NUMBER 2 DIGIT
; D REG. Y COORDINATE
; E REG. X COORDINATE
; HL POINTS TO NUMBER
; C OPTIONS BYTE
; B EXTENDED OPTIONS
NUM2:
        LD      B,$82
        LD      C,$09
        SYSTEM  DISNUM          ; UPI DISplay NUMber
        ;
        RET

; DO TABLE
DOITAB:
        DB      $5C             ; CALL MACHINE LANGUAGE
        DW      POTMOV          ; POT MOVED

        DB      $55             ; CALL MACHINE LANG.
        DW      JOYMOV          ; JOY STICK MOVED

        DB      $53             ; MACHINE CALL
        DW      PIZZA           ; KEY DOWN

        DB      $54             ; MACHINE LANG. CALL
        DW      TRIGMV          ; TRIGGER MOVED
        DB      $C0             ; END OF TABLE

; POT MOVED HANDLER
POTMOV:
        LD      IX,RCOWB        ; RIGHT COWBOY Vector Block
        LD      A,B
        AND     $E0
        RRCA
        RRCA
        RRCA
        RRCA
        CP      $0E
        JR      NZ,SEVSKP
        LD      A,$0C
SEVSKP: LD      (IX+$0F),A      ; ??
        RET

; JOYSTICK HANDLER
JOYMOV:
        LD      IX,RCOWB        ; Vector Block
        LD      C,(IX+VBMR)
        LD      HL,$0080        ; 128
        LD      A,(WPNOW)
        CP      $33             ; 51
        JR      NZ,WALKNG
        LD      HL,$0100        ; 256
WALKNG: PUSH    HL
        POP     DE
        SYSTEM  MSKTD           ; UPI MaSK joystick in B To Deltas
        ;
        LD      (IX+VBDYH),H
        LD      (IX+VBDYL),L
        LD      (IX+VBDXH),D
        LD      (IX+VBDXL),E
        LD      A,$10
        JR      Z,RGHTCW
        LD      A,$10
RGHTCW: LD      (IX+VBMR),A
        RET

; TRIGGER HANDLER
TRIGMV:
        LD      A,(WPNOW)
        CP      $32             ; 50
        RET     NZ
        SYSSUK  BMUSIC          ; UPI Begin playing MUSIC Gunshot
        DW      WRITQ           ; ... Music Stack = 20242 ($4F12)
        DB      $01             ; ... Voices = 1
        DW      GUNSHT          ; ... Score Address = 9445 ($24E5)
        ;
        RET

; KEYBOARD HANDLER
PIZZA:
        SYSTEM  KCTASC          ; UPI Key Code in B To ASCii
        ;
        CP      $31
        JR      NC,NECTST
PIZNOW: SYSTEM  PIZBRK          ; UPI take a PIZza BReaK
        ;
        RET

NECTST:
        CP      $35
        JR      NC,PIZNOW
        LD      (WPNOW),A       ; PRESENT WEAPON SAVED IN ASCII
L2302:
        LD      D,$00
        LD      E,$40           ; 64
        LD      C,$09
        SYSTEM  CHRDIS          ; UPI CHaRacter DISplay
        ;
        RET

; DELETE FROM QUEUE
  ; *** subroutine to DELete entry at front of Q
  ; Entry:        HL = head-tail, IX = object, A = clobbered
DELQ:
        DI
        LD      A,(IX+NEXT)     ; head = next(object)
        LD      (HL),A
        OR      A               ; is head now nil?
        RET     NZ              ; quit if not
        INC     HL              ; yes - set tail = nil too
        LD      (HL),A
        DEC     HL              ; BACK TO HEAD
        RET

; ADD TO QUEUE
  ; *** subroutine to APPend entry to end of Q
  ; Entry:        HL = head-tail bytes, IX = object, A, DE, C
ADDTQ:
        PUSH    IX              ; DE = entry
        POP     DE
        DI
        LD      (IX+NEXT),$00   ; next(obj) = nil
        INC     HL              ; H+
        LD      A,(HL)          ; A = old tail
        LD      (HL),E          ; set tail = .obj
        OR      A               ; was old tail nil?
        JR      Z,ADDTQ1                ; (+$06) jump if so
  ; nonnil old tail  set next(oldtail) = .obj
        LD      E,A             ; DE = .next(oldtail)
        LD      A,(HL)          ; A = obj (from new tail)
        DEC     HL              ; H-1
        DEC     DE              ; D-1
        LD      (DE),A
        RET

  ; nil old tail case           ; backup to head
ADDTQ1:
        DEC     HL              ; H-1
        LD      (HL),E          ; head = .obj
        RET

; POINT IX TO FIRST QUEUE ENTRY
  ; *** subroutine to point ix at FIRST entry on a q
  ; Entry:        HL = q head-tail
  ; Exit:         IX, DE = object, A = l.o. byte of object
  ;               nonzero status set if q not empty
FIRST:
        DI
        LD      E,(HL)
        INC     HL              ; H
        INC     HL              ; H
        LD      D,(HL)          ; D = h.o. addr. byte
        DEC     HL              ; H
        DEC     HL              ; H
        LD      A,E             ; E = head of q
        OR      A
        PUSH    DE
        POP     IX
        RET

; BUMP VECTOR TIME BASE
  ; *** Routine to BUMP Time base of vectors
TBUMP:
        LD      A,(HL)          ; get status
        INC     HL              ; H
        AND     $A0             ; active or intercepted?
        JR      Z,TBUMP1                ; (+$01) no - TBUMP1
        INC     (HL)            ; bump the time base
TBUMP1: ADD     HL,DE           ; H+D
        DJNZ    TBUMP                   ; (-$0a)
        RET

; ALTERNATE INTERRUPT HANDLER
  ; ************************************
  ; * GunFight write interrupt routine *
  ; ************************************
GFWRIT:
        EX      AF,AF'
        EXX
        PUSH    IX
        LD      A,LFRVEC AND $FF ; establish ticks int
        OUT     (INFBK),A
        LD      A,LFRLIN        ; TOP OF SCREEN
        OUT     (INLIN),A
        LD      HL,WRITQ        ; get first WRITe Q entry
        CALL    FIRST           ; FIRST
        CALL    DELQ            ; Drop from write Q
        XOR     A
        LD      (WASTE),A       ; 0->MAGIC->$4FFF
        LD      DE,$1405        ; BLANK GUNFIGHTER
        SYSTEM  VBLANK          ; UPI Vector BLANK area
        ;
  ; and write leg
        LD      H,LEG0 SHR 8    ; point at LEG PATTERN
        LD      L,(IX+VBLEG)
        INC     L               ; SKIP OVER LINK AND TIME
        INC     L
        SYSTEM  VWRITR          ; UPI Vector WRITe LEG Relative
        ;
        LD      HL,ARMTBL       ; lookup ARM TABLE
        LD      D,$00
        LD      E,(IX+VBARM)
        ADD     HL,DE           ; COMP. ADDRESS
        LD      E,(HL)
        INC     HL              ; NEXT BYTE
        LD      D,(HL)
        EX      DE,HL
  ; write arm pattern
        SYSTEM  VWRITR          ; UPI Vector WRITe ARM Relative
        ;
        LD      HL,GFBODY       ; load GUNFIGHTER BODY
        SYSTEM  VWRITR          ; UPI Vector WRITe BODY Relative
        ;
        LD      (IX+VBOAH),D    ; SAVE POSITION IN
        LD      (IX+VBOAL),E    ; OLD SCREEN ADDRESS
        LD      HL,VECQ         ; ADD VECTOR TO vector QUEUE
        CALL    ADDTQ           ; ADD Q
        POP     IX
        EXX
        EX      AF,AF'
        EI
        RET

; GUNFIGHTER LIMIT TABLE
GUNLMT:
        DB      $59             ; LEFT = 89
        DB      LCACX - $11     ; RIGHT = 133 ($85)
        DB      TLINE           ; TOP = 5 ($05)
        DB      BLINE - $14     ; BOTTOM = 66 ($42)

; PRIMARY INTERRUPT HANDLER
  ; ***********************************
  ; * GunFight Low Foreground Routine *
  ; ***********************************
GFLFR:
        PUSH    AF
        PUSH    BC
        PUSH    DE
        PUSH    HL
        PUSH    IX
        LD      DE,BULVSZ - 1   ; [$0016]
        LD      HL,RCOWB        ; Vector Block
        INC     HL              ; STATUS
        LD      B,$01
        CALL    TBUMP           ; TBUMP
  ; a word to our shifter
        XOR     A
        LD      (WASTE),A       ; SHIFTER
  ; get next pattern to write, and schedule him
GETVEC: LD      HL,WRITQ
        CALL    FIRST           ; FIRST
;         JP      Z,ENORUP
;         CALL    DELQ            ; DELQ
        JP      Z,L2758                 ; (+$12) jump if empty q
        JP      L2750           ; NEW CODE AREA FOR WORKING EPROM

  ; zero velocity?
L23B8:
        LD      A,(IX+VBDXL)
        OR      (IX+VBDXH)
        OR      (IX+VBDYL)
        OR      (IX+VBDYH)
        JR      NZ,MOVGF                ; (+$17) if non-zero
        LD      (IX+VBTIMB),A   ; zero time base
        BIT     VBSNOM,(IX+VBSTAT)  ; already stationary
        JR      NZ,STARMC
  ; set stationary legs
        LD      (IX+VBLEG),LEG0 AND $FF
        SET     VBSCHG,(IX+VBSTAT) ; set changed
        SET     VBSNOM,(IX+VBSTAT) ; and stationary
        JR      STARMC

MOVGF:
        NOP                     ; filler ??
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        NOP
        LD      HL,GUNLMT       ; load gf limits
; SEE IF EDGE
        SYSTEM  VECT            ; UPI VECTor move coordinate pair
        ;
        JR      Z,ANTIM         ; SEE IF MOVED
        SET     VBSCHG,(IX+VBSTAT) ; set CHANGED BIT
        RES     VBSNOM,(IX+VBSTAT) ; clear not MOVING STATUS
  ; was GVECT2: need we go to next cell in animation sequence?
ANTIM:  LD      A,(IX+VBLEGT)   ; A = animation timer
        SUB     C
        JP      P,STORTM        ; jump if not counted down
  ; get next cell
        LD      E,(IX+VBLEG)    ; get LEG LINK
        LD      D,LEG0 SHR 8    ; set HIGH ORDER LEG ADDRESS
        LD      A,(DE)          ; (DE)->A
        LD      (IX+VBLEG),A
        INC     DE              ; NEXT
        LD      A,(DE)          ; (DE)->A
        SET     VBSCHG,(IX+VBSTAT) ; set CHANGED BIT
  ; was GVECT3:
STORTM: LD      (IX+VBLEGT),A   ; store back timer
  ; was GVECT3A: did arm change?
STARMC: LD      A,(IX+VBARM)    ; GET ARM POSITION
        CP      (IX+VBOARM)     ; OLD ARM SAME?
        JR      Z,NOARMC        ; NO CHANGE JUMP
        SET     VBSCHG,(IX+VBSTAT) ; set CHANGED BIT
        LD      (IX+VBOARM),A   ; SAVE POS.
  ; was GVECT3B: add item to write q
NOARMC: BIT     VBSCHG,(IX+VBSTAT) ; CHANGED?
        JR      NZ,REMQUE       ; yes
  ; no change - link to vector q
        LD      HL,VECQ         ; VECTOR Q
        CALL    ADDTQ           ; ADD TO QUEUE
        DEC     B
        JP      NZ,GETVEC       ; sub for DJNZ
  ; was GVECT4:
NEWVEC: NOP                     ; filler
        NOP
        NOP
        EI
        CALL    STIMER          ; Seconds and game TIMER, music
; ENORUP: not used ??
        POP     IX
        POP     HL
        POP     DE
        POP     BC
        POP     AF
        EI
        RET

  ; was GVECT6:
REMQUE:
        RES     VBSCHG,(IX+VBSTAT)
        LD      HL,WRITQ        ; WRITQ
        CALL    ADDTQ           ; ADDTQ
        JR      NEWVEC

  ; for CT5-7, CNT, SEMI4S, OPOT1-4, KEYSEX, and OSW1-2
SINNIT:
        DB      $06,$06,$00,$00,$00,$30,$30,$00
        DB      $00,$80,$0F,$0F

  ; **********************
  ; * Gun Fight patterns *
  ; **********************

  ; ****** pattern tables
ARMTBL:
        DW      ARM0            ; fully CW
        DW      ARM1
        DW      ARM2
        DW      ARM3
        DW      ARM4
        DW      ARM5
        DW      ARM6            ; fully CCW

ARM0:           ; Color patterns
        DEF2    $0A, $0A        ; Offsets = 10 left, 10 down
        DEF2    $02, $05        ; Width = 2 bytes, Height = 5
        DEF2    $40, $00        ; 1 . . . . . . . [arms in color 1 only]
        DEF2    $51, $00        ; 1 1 . 1 . . . .
        DEF2    $04, $00        ; . . 1 . . . . .
        DEF2    $01, $00        ; . . . 1 . . . .
        DEF2    $00, $40        ; . . . . 1 . . .

ARM1:
        DEF2    $0A, $0A        ; Offsets = 10 left, 10 down
        DEF2    $02, $03        ; Width = 2 bytes, Height = 3
        DEF2    $50, $00        ; 1 1 . . . . . .
        DEF2    $14, $00        ; . 1 1 . . . . .
        DEF2    $01, $40        ; . . . 1 1 . . .

ARM2:
        DEF2    $0A, $0A        ; Offsets = 10 left, 10 down
        DEF2    $02, $02        ; Width = 2 bytes, Height = 2
        DEF2    $54, $00        ; 1 1 1 . . . . .
        DEF2    $55, $40        ; 1 1 1 1 1 . . .

ARM3:
        DEF2    $0A, $07        ; Offsets = 10 left, 7 down
        DEF2    $02, $04        ; Width = 2 bytes, Height = 4
        DEF2    $10, $00        ; . 1 . . . . . .
        DEF2    $05, $40        ; . . 1 1 1 . . .
        DEF2    $54, $00        ; 1 1 1 . . . . .
        DEF2    $50, $00        ; 1 1 . . . . . .

ARM4:
        DEF2    $0A, $06        ; Offsets = 10 left, 6 down
        DEF2    $02, $05        ; Width = 2 bytes, Height = 5
        DEF2    $00, $40        ; . . . . 1 . . .
        DEF2    $45, $00        ; 1 . 1 1 . . . .
        DEF2    $10, $00        ; . 1 . . . . . .
        DEF2    $50, $00        ; 1 1 . . . . . .
        DEF2    $40, $00        ; 1 . . . . . . .

ARM5:
        DEF2    $0A, $05        ; Offsets = 10 left, 5 down
        DEF2    $02, $06        ; Width = 2 bytes, Height = 6
        DEF2    $00, $40        ; . . . . 1 . . .
        DEF2    $01, $00        ; . . . 1 . . . .
        DEF2    $05, $00        ; . . 1 1 . . . .
        DEF2    $0E, $00        ; . . 3 2 . . . .  [was $14, $00 ??]
        DEF2    $54, $00        ; 1 1 1 . . . . .
        DEF2    $50, $00        ; 1 1 . . . . . .

ARM6:
        DEF2    $0A, $05        ; Offsets = 10 left, 5 down
        DEF2    $01, $05        ; Width = 1 byte, Height = 5
        DB      $01             ; . . . 1
        DB      $44             ; 1 . 1 .
        DB      $10             ; . 1 . .
        DB      $40             ; 1 . . .
        DB      $40             ; 1 . . .

GFBODY:         ; note: Hot Spot for parts displacement marked with ()'s
        DEF2    $00, $00        ; Offsets = 0, 0
        DEF2    $03, $0F        ; Width = 3 bytes, Height = 15
        DEF3    $00, $2C, $00   ;(.). . . . 2 3 . . . . .  [was $00, $44, $00 ??]
        DEF3    $11, $55, $10   ; . 1 . 1 1 1 1 1 . 1 . .
        DEF3    $15, $55, $50   ; . 1 1 1 1 1 1 1 1 1 . .
        DEF3    $02, $AA, $00   ; . . . 2 2 2 2 2 . . . .
        DEF3    $02, $A2, $00   ; . . . 2 2 2 . 2 . . . .
        DEF3    $02, $AA, $80   ; . . . 2 2 2 2 2 2 . . .
        DEF3    $00, $AA, $00   ; . . . . 2 2 2 2 . . . .
        DEF3    $00, $A8, $00   ; . . . . 2 2 2 . . . . .
        DEF3    $15, $55, $00   ; . 1 1 1 1 1 1 1 . . . .
        DEF3    $55, $55, $50   ; 1 1 1 1 1 1 1 1 1 1 . .
        DEF3    $51, $55, $50   ; 1 1 . 1 1 1 1 1 1 1 . .
        DEF3    $41, $55, $00   ; 1 . . 1 1 1 1 1 . . . .
        DEF3    $41, $55, $00   ; 1 . . 1 1 1 1 1 . . . .
        DEF3    $45, $55, $00   ; 1 . 1 1 1 1 1 1 . . . .
        DEF3    $01, $55, $00   ; . . . 1 1 1 1 1 . . . .

GUNSHT:
        OUTPUT  $18, $F0, $F5, $FD, $FF, $00, $3F, $FF, $EF
        LEGSTA
        VOLUME  $FF, $3F
        REST    $05
        NOTE1   $05, $8F
        NOTE1   $05, $4C
        QUIET

; NEXT LINE THEN
LFNUM1:
        CALL    NXTLN
; 1 BCD CHARACTER
ONEBCD: LD      C,$09
        LD      B,$81
        SYSTEM  DISNUM          ; UPI DISplay BCD NUMber OUT
        ;
        RET

; CONSTANTS TABLE
RACES:  DB      'HUMELFHAFDWA'

TRAITS: DB      'STRINTWISCONDEXCHA'

TYPE:   DB      'FI   AC2MU  AC10CL   AC3TH   AC6'

WEAP:   DB      'WEAP'

AMMO1:  DB      'SWRDARRODAGRLTNGMACEHOLDDAGRHIDE'

AMMO2:  DB      'RUN TAKE'

; YE ROYAL DUNGEON
DOORTB:
        DB      $42,$77,$35,$54,$57,$35,$76,$37
        DB      $3E,$CA,$F5,$77,$5F,$D7,$9E,$DC
        DB      $9E,$7E,$E3,$AB,$6A,$8D,$3E,$B6
        DB      $4A,$DD,$EB,$CB,$FD,$6B,$DF,$AB
        DB      $5C,$77,$C9,$5F,$D5,$DF,$2B,$BC
        DB      $22,$AA,$36,$7E,$23,$5C,$E9,$95
        DB      $EA,$DD,$FF,$DD,$E9,$75,$B5,$36
        DB      $FE,$77,$BD,$74,$B5,$F6,$95,$AA
        DB      $DC,$9F,$C2,$A3,$F6,$9F,$56,$AD
        DB      $36,$68,$3F,$C8,$A9,$68,$7F,$97
        DB      $FE,$A3,$E8,$63,$E3,$F7,$E9,$1D
        DB      $FE,$CB,$F5,$DD,$EB,$9D,$F6,$15
        DB      $AA,$7E,$A3,$62,$89,$56,$DF,$37
        DB      $9E,$DE,$AB,$CA,$17,$6A,$1F,$9E
        DB      $3C,$5C,$CB,$1F,$4A,$E9,$4B,$3F
        DB      $D4,$15,$5C,$1D,$5C,$D5,$1D,$9C

FAWN:   DB      'FAWN DUNGEON',$00

NUMHIT: DB      'NO. OF HITS',$00

COLORS: DB      $73,$07,$FA,$9D ; LEFT 4-7 DEEP RED,WHITE,MAGEN
        DB      $FA,$76,$5A,$01 ; RIGHT 0-3 BLUE,FLESH,RED,GRAY
;
        DB      $FF,$FF         ; UNUSED
;
; NEW CODE FROM EPROM THAT WORKS
;         ORG     $2610 ?? not used ??
        LD      (IX+VBDXL),$CE
        LD      (IX+VBDXH),$FF
        RET

        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF

;         ORG     $2620
L2620:
        LD      (IX+VBDXL),$32
        LD      (IX+VBDXH),$00
        RET

        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF

;         ORG     $2630 ?? not used ??
        XOR     A
        OUT     (INLIN),A
        LD      A,WRTVEC AND $FF
        OUT     (INFBK),A
        EI
        LD      HL,VECQ
        CALL    FIRST           ; [$232D]
        JP      Z,NEWVEC        ; [$242C]
        CALL    DELQ            ; [$230B]
        EI
        RET

; END OF NEW FROM EPROM
;
; UNUSED BYTES OF STORAGE FROM EPROM
;         ORG     $2646
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF

; NEW CODE FROM EPROM VERSION THAT WORKS
;        ORG     $26F0           ; NEW CODE FROM WORKING VERSION
L26F0:
        LD      SP,STACK
        SYSTEM  INTPC           ; UPI INTERPRET WITH CONTEXt CREATE
;
        DO      COLSET          ; UPI COLORS SET
        DW      COLORS          ; ... TABLE ADDRESS = $2606
;
        DO      FILL            ; UPI FILL MEMORY WITH DATA
        DW      STACK           ; ... MEMORY ADDRESS = 20230 ($4F06)
        DW      $0088           ; ... BYTE COUNT = 136
        DB      $00             ; ... DATA = 0
;
        DO      SETOUT          ; UPI SET SOME OUTPUT PORTS
        DB      $B8             ; ... VERBL*2 = 184
        DB      $14             ; ... HORCB/4 = 20
        DB      $08             ; ... INMOD = Screen Interrupts ONLY
;
        DO      MOVE            ; UPI MOVE BLOCK TRANSFER for sentry
        DW      CT5             ; ... DESTINATION ADDRESS = 20442 ($4FDA)
        DW      $000C           ; ... BYTE COUNT = 12
        DW      SINNIT          ; ... SOURCE ADDRESS = 9287 ($2447)
;
        DONT    XINTC           ; UPI EXIT INTERPRETER WITH CONTEXT
;
        LD      DE,RACES
        JP      L2084

L2710:
        LD      A,(WPNOW)
        CALL    L2302
        LD      A,(ROOM)
        JP      L212F
;
        DB      $FF,$FF,$FF     ; EMPTY STORAGE AREA
;
        LD      SP,STACK
        SYSSUK  MOVE            ; UPI MOVE BLOCK TRANSFER
        DW      CT5             ; ... DESTINATION ADDRESS = 20442 ($4FDA)
        DW      $000C           ; ... BYTE COUNT = 12
        DW      SINNIT          ; ... SOURCE ADDRESS = $2447
;
        LD      DE,RACES        ; [$2503]
        JP      L2084

L2730:
        LD      A,(IX+VBYH)
        CP      $32
        XOR     A
        JR      NC,L273A
        LD      A,$6A
L273A:
        SBC     A,$0F
        JP      L2753
;
        DB      $FF             ; EMPTY STORAGE AREA
;
KLUDGE1:
        LD      A,$05
        CP      D
        JP      NZ,NTPWL
        JP      $21E7
;
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF ; EMPTY STORAGE AREA
;
L2750:
        JP      L2730

L2753:
        LD      A,WRTVEC AND $FF  ; set feedback register [$FE]
        OUT     (INFBK),A
        EI                      ; [too soon??]
L2758:
        LD      HL,VECQ
        CALL    FIRST           ; first vector q entry
        JP      Z,NEWVEC        ; jump [$242C] if q is empty
        CALL    DELQ            ; [$230B] Drop from vector Q
        EI
        JP      L23B8           ; back

; END OF NEW AREA
;
; 40 UNUSED BYTES
;         ORG     $2768
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
;
; NEW CODE FROM VERSION THAT WORKS (32 TOTAL BYTES)
;        ORG     $2790           ; NEW CODE FROM WORKING VERSION
L2790:
        LD      (IX+VBDXH),$FF
        JP      NXPSB1

L2797:
        LD      (IX+VBDXL),$32
        LD      (IX+VBDXH),$00
db $C3
;         JP      NXPSB1 [split ??]

; stub ?? WAS, LD  A,(RELX)
L27A0:
db $5D   ; now ld e,l ??
db $22   ; now ld ($fe4f),hl and sbb e ??
; L27A2: stub here instead ??
        LD      C,A
        CP      $9B
        LD      A,$04
        JP      Z,L2241         ; back
        LD      A,$88
        JP      L2241

        DB      $FF             ; EXTRA STORAGE
; NEW CODE (END OF 32 BYTES)
;
; LEG TABLES
;         ORG     $27B0
  ; **** NOTE ****
  ; THE FOLLOWING PATTERNS ARE CONSTRAINED TO EXIST ON THE
  ; PAGE.  <ORG ($+255) AND 0FF00H> WILL DO IT FOR EXPERIMENTAL
  ; PATTERNS ARE: LEG0, LEG1, LEG2, KIL1, KIL2
  ; ***
LEG0:
        DB      LEG1 AND $FF    ; Next in animation cycle
        DB      $04             ; Delay time setting = 4
        DEF2    $00, $0F        ; Offsets = 0, 15 down
        DEF2    $03, $05        ; Width = 3 bytes, Height = 5
        DEF3    $01, $55, $00   ; . . . 1 1 1 1 1 . . . . [... legs too]
        DEF3    $05, $45, $40   ; . . 1 1 1 . 1 1 1 . . .
        DEF3    $15, $01, $40   ; . 1 1 1 . . . 1 1 . . .
        DEF3    $50, $01, $40   ; 1 1 . . . . . 1 1 . . .
        DEF3    $15, $00, $54   ; . 1 1 1 . . . . 1 1 1 .

LEG1:
        DB      LEG2 AND $FF    ; Next in cycle
        DB      $04             ; Delay time
        DEF2    $02, $0F        ; Offsets = 2 left, 15 down
        DEF2    $02, $05        ; Width = 2 bytes, Height = 5
        DEF2    $15, $50        ; . 1 1 1 1 1 . .
        DEF2    $54, $50        ; 1 1 1 . 1 1 . .
        DEF2    $50, $50        ; 1 1 . . 1 1 . .
        DEF2    $50, $50        ; 1 1 . . 1 1 . .
        DEF2    $55, $15        ; 1 1 1 1 . 1 1 1

LEG2:
        DB      LEG0 AND $FF    ; LOOP back to start
        DB      $04             ; Delay
        DEF2    $03, $0F        ; Offsets = 3 left, 15 down
        DEF2    $02, $05        ; Width = 2 bytes, Height = 5
        DEF2    $55, $00        ; 1 1 1 1 . . . .
        DEF2    $15, $00        ; . 1 1 1 . . . .
        DEF2    $15, $00        ; . 1 1 1 . . . .
        DEF2    $14, $00        ; . 1 1 . . . . .
        DEF2    $05, $40        ; . . 1 1 1 . . .

; 23 BYTES OF UNUSED STORAGE FOR EPROM
;         ORG     $27E5
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF
;
; INTERRUPT VECTORS
;         ORG     $27FC
INTTBL:         ; INTerrupt TaBLe
LFRVEC:
        DW      GFLFR           ; Low Foreground Routine VECtor

WRTVEC: DW      GFWRIT          ; GunFighter WRiTe VECtor

  ;
  ;       END of Fawn Dungeon program
  ;
