Please enable JavaScript to display the menu.
Fujitsu FM-7 Retro Game Joystick Patch - Delphis

ysflight.com

Delphis (COMPAC, Published in I/O magazine May 1984 issue, Hironori Hattori)

Delphis was a vertical scroll shooter developed for Fujitsu FM-7 8-bit retro PC.  The program was published in I/O magazine February 1985 issue, and then sold from COMPAC.  Not to mistake with COMPAQ.  Those are different companies.  Xevious of namco was a big hit then.  I really wanted to play and wanted to type in the code published on the magazine.  But, the quantity of the code was enormous.  I saved my allowances and purchased a copy later.

Fujitsu FM-7 was able to scroll the screen vertically 2 pixels at a time, which was very special back then.  Delphis made use of this functionality.  Scrolling of the field was very smooth in 1985 standard.  Also what's smart about the author was he chose to use one in every four pixels for the background, and the rest three for other game characters.  PCs in 1985 didn't come with multiple layers of screen.  There was an option to use Red, Green, and Blue planes separately just like layers, but that usage limits at least one layer only single color, and the other up to three colors.  Delphis solved the layering problem by this technique.

I don't remember which came first, but Xevious was ported to FM-7 by DEMPA in an appalling quality.  I purchased and played it anyway, but it was quite disappointing.  DEMPA also sold "Tiny Xevious", a port of Xevious for PC6601.  The screen appeared greenish due to the limited performance of PC6601.  FM-7 was supposed to be a much better PC, but the screen of the FM-7 port was greenish.  It was scrolling 8 pixels at a time.  I was always killed by "Brag Zakato" (the black sphere with red dot in the middle called) that shoots five bullets at a time in the arcade version (no matter how many Solvalous left, my game was over at the beginning of AREA 14.)  In FM-7 version, it was not a big deal to avoid all bullets shot from Brag Zakatoes because it was so slow.  Later DEMPA ported "The Tower of Druaga" and "Dragon Buster" to FM77AV in extraordinary high quality, but FM-7 port of Xevious permanently damaged the reputation of DEMPA among FM-7 users.  The presence of Delphis gave some ease to the FM-7 users by proving that FM-7 is capable of vertical-scrolling shooters.

However, the playability of Delphis was pretty bad.  FM-7 is famous for not able to sense key-release event.  FM-7 gamers learned to press '5' key (in the middle of num keys) to stop the player character.  It was not too bad because I didn't have to keep holding the key to move a character.  It probably was gnetle for my wrist.  But, for whatever reason, the author chose to use 1,2,3, and 5 keys on the num pad to move the player airplane.  There was no key in between 3 and 5, and I couldn't stop it easily.  That was still ok.  Maybe it was not too bad to keep moving in the game to avoid enemys' missiles.  But, when I pressed '0' for dropping a bomb, the fighter stopped.  I moved my fighter to the bomb-release position avoiding missiles, and pressed '0'.  Bombs away!  And then the fighter stopped there like a sitting duck and shot down.  That was unreasnably difficult.

I think I played all the way by using a invulnerable mode.

Due to a historic impact on FM-7 community, Delphis is one of the games that you would want to run on FM-7 if you restore one and put on display.  But, for younger gamers the usability may be an issue.  So, here you can download a patch to add joystick support to Delphis.  Actually I found a bug in 2018 (33 years after the program was published).  I don't remember I had an issue in starting the program.  I don't know why it was running in 1985.  I patched this bug also.  The program assumes you turn on CAPS lock, but with this patch you won't have to.  Once you start the program, you can control pretty much everything with a joystick.

Bug found in 2018

While I was trying to run it on my FM77AV40 and FM-7, the program stopped in the middle.  It started once every several times, but most of the time it didn't.  I looked into the code and found a bug in SubCPU control part.  The starting sequence of Delphis is (1) the first program transfers data and code to shadow RAM ($8000-$FBFF) and Sub CPU memory space, and then (2) the second and main program starts.  In (1) the program was not correctly halting the Sub CPU.  This bug can be patched by the following loader.

10 CLEAR ,&H14FF
20 LOADM"DATA"
30 POKE &H68B1,&HFD
40 POKE &H68B2,&H05
50 POKE &H68B3,&H2A
60 POKE &H68B4,&HFB
70 EXEC
80 LOADM"DELPH.M"
90 POKE &H560D,&HFD
100 POKE &H560E,&H05
110 POKE &H560F,&H2A
120 POKE &H5610,&HFB
130 EXEC

The correct way to halt the Sub CPU is (1) write $80 to [$FD05] and (2) wait for [$FD05] bit 7 turns zero.  Delphis was skipping (2).  Unless the Sub CPU halted in the next CPU cycle follwing (1), the program didn't start.  I wonder why I didn't have problem in starting it in 1985.  I confirmed that the bug was in the code published in I/O magazine as well as the version sold in the audio-cassette media.

Supporting Joystick

FM-7/new7, FM-77D1/D2 can connect up to two MSX joysticks.  Not ATARI joystick.  You need to be careful.  ATARI and MSX joysticks have different pin assignment although both connects to D-Sub 9.  I am in process of reverse engineering YM2203C expansion card that also adds joystick port for FM-7.  I will upload the circuit diagram in this web site soon, if I goes successful.

To add joystick support in Delphis, you need to type in the following F-BASIC code and a bianry code.

SAVE "DELPHJS"

10 CLEAR 20,&H13FF
20 LOADM "DELPHJSM"
30 LOADM "DATA"
40 POKE &H68B1,&HFD
50 POKE &H68B2,&H05
60 POKE &H68B3,&H2A
70 POKE &H68B4,&HFB
80 EXEC
90 LOADM "DELPH.M"
100 POKE &H560D,&HFD
110 POKE &H560E,&H05
120 POKE &H560F,&H2A
130 POKE &H5610,&HFB
140 EXEC &H1400

SAVEM "DELPHJSM",&H1400,&H153E,&H1400

Add +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F Sum
1400 17 01 02 86 7E B7 52 C1 30 8C 2C BF 52 C2 86 BD :E6 |....~.R.0.,.R...
1410 30 8D 00 E3 B7 55 F7 BF 55 F8 30 8D 00 C0 B7 42 :25 |0....U..U.0....B
1420 2A BF 42 2B 30 8D 00 A1 B7 42 EF BF 42 F0 B7 42 :86 |*.B+0....B..B..B
1430 1B BF 42 1C 7E 33 00 34 7D 4F 17 00 D3 34 02 85 :8E |..B.~3.4}O...4..
1440 20 26 11 C6 58 7D 23 E6 27 07 7D 23 E7 26 05 C6 :A1 | &..X}#.'.}#.&..
1450 5A F7 22 09 85 10 26 0A FC 16 31 26 05 C6 30 F7 :9C |Z."...&...1&..0.
1460 22 09 4F C6 01 E4 E4 26 0F F6 16 2E 5A C1 0F 25 :C7 |".O....&....Z..%
1470 07 F7 16 2E 8A 01 20 13 C6 02 E4 E4 26 0D F6 16 :CF |...... .....&...
1480 2E 5C C1 2D 2C 05 F7 16 2E 8A 04 C6 04 E4 E4 26 :2A |.\.-,..........&
1490 0F F6 16 1A 5A C1 07 25 07 F7 16 1A 8A 10 20 13 :77 |....Z..%...... .
14A0 C6 08 E4 E4 26 13 F6 16 1A 5C C1 42 2C 0B F7 16 :98 |....&....\.B,...
14B0 1A 8A 08 85 07 26 02 8A 02 35 04 35 7D 4D 27 03 :4E |.....&...5.5}M'.
14C0 7E 53 1A B6 22 09 7E 52 C4 34 04 4F 8D 42 84 30 :6A |~S..".~R.4.O.B.0
14D0 81 30 27 05 86 20 B7 22 09 B6 22 09 35 84 BD 43 :FF |.0'.. ."..".5..C
14E0 E8 34 04 4F 8D 2A 84 30 81 30 27 05 86 42 B7 22 :58 |.4.O.*.0.0'..B."
14F0 09 35 04 B6 22 09 39 81 61 25 06 81 7A 2E 02 8B :1F |.5..".9.a%..z...
---------------------------------------------------------
     3C F9 2A E3 55 99 7E 7E B1 7B 3C 9B CC E2 4C 30

Add +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F Sum
1500 E0 B7 22 09 39 CC 0F 7F 8D 20 CC 07 BF 20 1B 39 :08 |..".9... ... .9
1510 C6 2F 84 01 27 02 C6 5F 86 0F 8D 0E 86 0E 8D 13 :2C |./..'.._........
1520 86 09 B7 FD 15 B6 FD 16 20 11 8D 07 F7 FD 16 86 :76 |........ .......
1530 02 20 05 B7 FD 16 86 03 B7 FD 15 7F FD 15 39    :0D |. ...........9.
---------------------------------------------------------
     2E 0F 62 BE 72 9A 58 F7 EA 3D FB 9B 39 40 F7 D2

The program needs to be saved in the audio-cassette media in the following order: DELPHJS, DELPHJSM, DATA, DELPH.M.  Or you can have them all on a floppydisk.

Or, if you have a tape image of Delphis (say delphis.t77), you can download this .T77 tape image, and t77save.exe from here, and concatinate them by:

t77save.exe -new Delphis_JS.t77 -append delphjs.t77 -append delphis.t77

Then you can start FM-7, set the cassette (or cassette image if you are running an emulator) and type:

RUN ""

to start Delphis.

Assembly Code of the Patch

                        ORG     $1400

JS_FLAG_UP              EQU     1
JS_FLAG_DOWN            EQU     2
JS_FLAG_LEFT            EQU     4
JS_FLAG_RIGHT           EQU     8
JS_FLAG_ABUTTON         EQU     16
JS_FLAG_BBUTTON         EQU     32


KEY_CODE                EQU     $2209
X_COORD                 EQU     $161A
Y_COORD                 EQU     $162E
KEY_TO_GUN_FLAG1        EQU     $23E6
KEY_TO_GUN_FLAG2        EQU     $23E7
BOMB_READY_2BYTE        EQU     $1631
INKEY_FUNC              EQU     $43E8


INSTALL_AND_RUN         LBSR    JSInit

                        LDA     #$7E        ; JMP
                        STA     $52C1
                        LEAX    DELPHIS_JS,PCR
                        STX     $52C2       ; Make it JMP DELPHIS_JS

                        LDA     #$BD        ; JSR

                        LEAX    CAPITALIZE,PCR
                        STA     $55F7
                        STX     $55F8

                        ;   422A 17 01 BB       LBSR  $43E8
                        LEAX    GAME_TYPE_CHECK,PCR
                        STA     $422A
                        STX     $422B

                        ;   42EF B6 22 09       LDA   $2209
                        LEAX    DEMO_STOP_CHECK,PCR
                        STA     $42EF
                        STX     $42F0

                        ;   421B B6 22 09       LDA   $2209
                        STA     $421B
                        STX     $421C

                        JMP     $3300

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

DELPHIS_JS              PSHS    B,X,Y,U,CC,DP

                        CLRA
                        LBSR    JSRead
                        PSHS    A



                        BITA    #JS_FLAG_BBUTTON
                        BNE     NOT_GUN_BUTTON
                        LDB     #'X'
                        TST     KEY_TO_GUN_FLAG1
                        BEQ     GUN_BUTTON_SETKEY
                        TST     KEY_TO_GUN_FLAG2
                        BNE     NOT_GUN_BUTTON
                        LDB     #'Z'
GUN_BUTTON_SETKEY       STB     KEY_CODE
NOT_GUN_BUTTON



                        BITA    #JS_FLAG_ABUTTON
                        BNE     NOT_BOMB_BUTTON
                        LDD     BOMB_READY_2BYTE
                        BNE     NOT_BOMB_BUTTON     ; Must be zero.
                        LDB     #'0'
                        STB     KEY_CODE
NOT_BOMB_BUTTON



                        CLRA

                        LDB     #JS_FLAG_UP
                        ANDB    ,S
                        BNE     NOT_UP

                        LDB     Y_COORD
                        DECB
                        CMPB    #$0F
                        BCS     NOT_UP

                        STB     Y_COORD
                        ORA     #1
                        BRA     NOT_DOWN

NOT_UP                  LDB     #JS_FLAG_DOWN
                        ANDB    ,S
                        BNE     NOT_DOWN

                        LDB     Y_COORD
                        INCB
                        CMPB    #$2D
                        BGE     NOT_DOWN

                        STB     Y_COORD
                        ORA     #4


NOT_DOWN                LDB     #JS_FLAG_LEFT
                        ANDB    ,S
                        BNE     NOT_LEFT

                        LDB     X_COORD
                        DECB
                        CMPB    #7
                        BCS     NOT_LEFT

                        STB     X_COORD
                        ORA     #$10
                        BRA     LEFT_OR_RIGHT

NOT_LEFT                LDB     #JS_FLAG_RIGHT
                        ANDB    ,S
                        BNE     NOT_RIGHT

                        LDB     X_COORD
                        INCB
                        CMPB    #$42
                        BGE     NOT_RIGHT

                        STB     X_COORD
                        ORA     #$08

LEFT_OR_RIGHT           BITA    #7
                        BNE     NOT_RIGHT
                        ORA     #2
NOT_RIGHT

                        PULS    B
                        PULS    B,X,Y,U,CC,DP
                        TSTA
                        BEQ     DELPH_NOTMOVED
DELPH_MOVED
                        ; If moved
                        JMP     $531A

DELPH_NOTMOVED
                        ; If no move
                        LDA     $2209
                        JMP     $52C4


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

DEMO_STOP_CHECK         PSHS    B
                        CLRA
                        BSR     JSRead
                        ANDA    #JS_FLAG_ABUTTON+JS_FLAG_BBUTTON
                        CMPA    #JS_FLAG_ABUTTON+JS_FLAG_BBUTTON
                        BEQ     DEMO_STOP_CHECK_EXIT
                        LDA     #' '
                        STA     KEY_CODE
DEMO_STOP_CHECK_EXIT    LDA     KEY_CODE
                        PULS    B,PC

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

GAME_TYPE_CHECK         JSR     INKEY_FUNC
                        PSHS    B
                        CLRA
                        BSR     JSRead
                        ANDA    #JS_FLAG_ABUTTON+JS_FLAG_BBUTTON
                        CMPA    #JS_FLAG_ABUTTON+JS_FLAG_BBUTTON
                        BEQ     EXIT_GAME_TYPE_CHECK
                        LDA     #'B'
                        STA     KEY_CODE
EXIT_GAME_TYPE_CHECK    PULS    B
                        LDA     KEY_CODE
                        RTS

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

CAPITALIZE              CMPA    #'a'
                        BLO     CAPITALIZE_SETKEY
                        CMPA    #'z'
                        BGT     CAPITALIZE_SETKEY
                        ADDA    #'A'-'a'
CAPITALIZE_SETKEY       STA     KEY_CODE
                        RTS

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

IO_FM_CMD               EQU     $FD15
IO_FM_DATA              EQU     $FD16

FM_CMD_LATCH            EQU     3
FM_CMD_WRITE            EQU     2
FM_CMD_READ             EQU     9

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

JSInit                  LDD     #$0F7F  ; Reg 15 <- $7F
                        BSR     FMWrite
                        LDD     #$07BF  ; Reg 7 <- $BF
                        BRA     FMWrite
                        RTS

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

                        ; A 0->JS0  1->JS1
JSRead                  LDB     #$2F
                        ANDA    #1
                        BEQ     JSRead0
                        LDB     #$5F
JSRead0                 LDA     #$0F    ; Reg 15 < $2F or $5F
                        BSR     FMWrite

                        LDA     #14
                        BSR     FMLatchRegister
                        LDA     #9
                        STA     IO_FM_CMD
                        LDA     IO_FM_DATA
                        BRA     FMClearCommand

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

                        ; A Register
                        ; B Data
FMWrite                 BSR     FMLatchRegister
                        STB     IO_FM_DATA
                        LDA     #FM_CMD_WRITE
                        BRA     FMWriteCommand

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

                        ; A Register
FMLatchRegister         STA     IO_FM_DATA
                        LDA     #FM_CMD_LATCH

FMWriteCommand          STA     IO_FM_CMD
FMClearCommand          CLR     IO_FM_CMD
                        RTS

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

                        END     INSTALL_AND_RUN

Comments are welcome.  Send E-Mail to: 

Back to http://www.ysflight.com