Please enable JavaScript to display the menu.
"Emergency" for Fujitsu FM-7 Joystick-Supporting Patch

ysflight.com

Emergency (COMPAC, I/O Magazine February 1984 issue, by T. Matuzaki)

"Emergency" (The title screen says "The Emergency", but it was just "Emergency" on the I/O magazine article) was 3D wireframe shooter published in I/O magazine February 1984 issue.  The game was pretty simple.  You need to strafe a target moving on the ground.  The game was boasting blazingly fast 5 frames per second, which was blazing in 1984 8-bit computer standard.  Actually the 3D scene consists of only up to 22 lines.  Nonetheless, it was impressive back then.  It is one of the games that FM-7 users remember.

The secret of the blazingly fast graphics was from the nearly 100% usage of the two 6809s of FM-7.  Many of the FM-7 programs used main CPU for general computation and sub CPU for graphics.  That made considerable idle time of the sub CPU.  This title let sub CPU do more task.  For example, sub CPU detects space-key press, render bullets on the screen, then notified main CPU that the player shot a gun.

Now it multi-threaded programming is so common, and running programs in parallel is nothing special.  However, in 1984, there was a discussion if 2-CPU design of FM-7 was a right decision.  Having multiple CPUs a waste?  This title, "Emergency", shot down those questions.  Yes, having two CPUs was a very much a good design.  Fujitsu had been making personal computers that were three steps, four steps, ahead of other computers.  But, always Fujitsu was too early and never able to become a majority.  This tradition continued all the way up to FM TOWNS series, until Fujitsu gave up on designing own computers with boring FM-V.

Emergency is one of the FM-7 games that needs to be remembered.  However, it does not support a joystick.  Probably it is difficult for younger gamers to fly with num keys.  So, I wrote a patch for supporting joysticks.  If your FM-7 has YM2203 card, or if you have FM77AV or newer model, you can play this title with a MSX joystick (not ATARI although both ATARI and MSX joysticks connects to D-Sub 9.  Pin assignments are different.)

Since you need to modify F-BASIC part, you need to make a media with an FM-7 emulator, or actual FM-7 hardware.  You can probably do it with an actual hardware + Tape Bios Redicrector, or Disk Bios Redirector.

Creating a Joystick-Supporting Patch

(1) Get an empty cassette-tape media, a floppy disk, or an empty tape/disk image if you do on an emulator or with a BIOS redirector.

(2) In FM-7, type in the following F-BASIC code, and SAVE "EMERGJS"

10 CLEAR ,&H3AFF
20 LOADM "EMERGJSM"
30 LOADM "emerg.m"
40 RUN "EMER"

(3) Type the following command in the F-BASIC prompt.

CLEAR ,&H3AFF

(4) Type in following dump list, and SAVEM "EMERGJSM",&H3B00,&H3C20,&H3B00

Add   +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F Sum
3B00  20 1C 20 06 20 01 00 16 00 AF 34 06 6F 8C F7 4F :C3 | . . .....4.o..O
3B10  17 00 B1 84 30 81 30 27 03 6C 8C EA 35 86 17 00 :0B |....0.0'.l..5...
3B20  98 B6 FD 05 2B FB 86 80 B7 FD 05 B6 FD 05 2A FB :12 |....+.........*.
3B30  30 8D 00 C0 10 8E FC 80 C6 2D A6 80 A7 A0 5A 26 :77 |0........-....Z&
3B40  F9 7F FD 05 B6 FD 05 2B FB 86 BD B7 63 5E 8E C9 :6A |......+....c^..
3B50  00 BF 63 5F 8E C8 FF BF 63 66 8E 12 12 BF 56 C5 :EA |..c_....cf....V.
3B60  86 BD B7 56 90 30 8C 06 BF 56 91 7E 53 00 34 7D :CA |...V.0...V.~S.4}
3B70  4F 8D 51 85 10 26 06 C6 80 DA 39 D7 39 1F 89 C4 :C3 |O.Q..&....9.9...
3B80  0F C1 0F 26 05 A1 8C 30 27 29 C6 30 85 04 26 04 :60 |...&...0').0..&.
3B90  C6 37 20 18 85 08 26 04 C6 39 20 10 85 01 26 04 :CB |.7 ...&..9 ...&.
3BA0  C6 38 20 08 85 02 26 04 C6 32 20 00 A7 8C 09 1F :4A |.8 ...&..2 .....
3BB0  98 35 FD B6 FD 01 35 FD 00 CC 0F 7F 8D 20 CC 07 :8A |.5....5..... ..
3BC0  BF 20 1B 39 C6 2F 84 01 27 02 C6 5F 86 0F 8D 0E :2B |. .9./..'.._....
3BD0  86 0E 8D 13 86 09 B7 FD 15 B6 FD 16 20 11 8D 07 :1A |............ ...
3BE0  F7 FD 16 86 02 20 05 B7 FD 16 86 03 B7 FD 15 7F :52 |..... .........
3BF0  FD 15 39 00 00 00 3F 59 41 4D 41 55 43 48 49 91 :6C |..9...?YAMAUCHI.
---------------------------------------------------------
      39 8C 79 5C C9 2A D4 36 4A DC 1F D0 27 09 CC 92

Add   +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F Sum
3C00  D3 93 C9 00 00 1A 90 B6 D4 01 B7 C8 FF B6 D3 80 :EB |................
3C10  2A 09 86 01 97 04 86 20 B7 C8 FF 96 04 7F D3 81 :E6 |*...... .......
3C20  39                                              :39 |9...............
---------------------------------------------------------
      36 9C 4F 01 97 1E 16 D6 8B C9 B6 5E 03 35 A6 01

(5) Load the binary part of the Emergency from whatever media you have.  Probably you have to do LOADM "emerg.m" on F-BASIC prompt.

(6) Set the media you prepared in step (1) and

SAVEM "emerg.m",&H3D00,&H6FFF,&H5300

("emerg.m" looks to be the file name used in the package version sold from COMPAC.  I typed in the list published on the I/O magazine, so I couldn't confirm it was really the filename used by COMPAC version.)

(7) Load the F-BASIC part of the Emergency from whatever media you have, and make the following modifications.

1100 CLEAR 300,&H3AFF:SCREEN 7,7:DIM HIS(5):COLOR 5

1105 EXEC &H3B04

2350 EXEC &H3B00

1190 A$=INKEY$:EXEC &H3B02:IF A$<>" " AND PEEK(&H3B06)=0 THEN 1190

1900 A$=INKEY$:EXEC &H3B02:IF A$<>" " AND PEEK(&H3B06)=0 THEN 1900

2370 A$=INKEY$:EXEC &H3B02:IF A$<>" " AND PEEK(&H3B06)=0 THEN 2370

3210 A$=INKEY$:EXEC &H3B02:IF A$<>" " AND PEEK(&H3B06)=0 THEN 3210

3800 A$=INKEY$:EXEC &H3B02:IF A$<>" " AND PEEK(&H3B06)=0 THEN 3800

(8) Set the media you prepared in step (1) and then type:

SAVE "EMER"

After doing this, you should be able to start Emergency with joystick support by typing  RUN "EMER"

Assembly Code of the Patch

                        ORG     $3B00


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

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

INSTALL_AND_RUN         BRA     INSTALL_MAIN                    ; $3B00
                        BRA     EMERGENCY_READ_JOYSTICK_BUTTON  ; $3B02
                        BRA     EMERGENCY_JSINIT
BUTTONPRESS             FCB     0


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

EMERGENCY_JSINIT        LBRA    JSInit

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

EMERGENCY_READ_JOYSTICK_BUTTON
                        ; For F-BASIC part
                        PSHS    A,B
                        CLR     BUTTONPRESS,PCR
                        CLRA
                        LBSR    JSRead
                        ANDA    #JS_FLAG_ABUTTON+JS_FLAG_BBUTTON
                        CMPA    #JS_FLAG_ABUTTON+JS_FLAG_BBUTTON
                        BEQ     EXIT_EMERGENCY_READ_JOYSTICK_BUTTON
                        INC     BUTTONPRESS,PCR
EXIT_EMERGENCY_READ_JOYSTICK_BUTTON
                        PULS    A,B,PC

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

INSTALL_MAIN            LBSR    JSInit

SUBSYS_READY_WAIT       LDA     $FD05
                        BMI     SUBSYS_READY_WAIT

                        LDA     #$80
                        STA     $FD05
SUBSYS_HALT_WAIT        LDA     $FD05
                        BPL     SUBSYS_HALT_WAIT

                        LEAX    SUBSYS_CMD,PCR
                        LDY     #$FC80
                        LDB     #SUBSYS_CMD_END-SUBSYS_CMD
SUBSYS_TFR_LOOP         LDA     ,X+
                        STA     ,Y+
                        DECB
                        BNE     SUBSYS_TFR_LOOP

                        CLR     $FD05
SUBSYS_UNHALT_WAIT      LDA     $FD05
                        BMI     SUBSYS_UNHALT_WAIT


                        ; 635E(C05E)    CLR     $D381 -> JSR    $C900
                        LDA     #$BD
                        STA     $635E
                        LDX     #$C900
                        STX     $635F

                        ; 6365(C065)    LDA     $D401 -> LDA    $C8FF
                        LDX     #$C8FF
                        STX     $6366

                        ; Stop with '5' key
                        LDX     #$1212
                        STX     $56C5

                        ; 5690  LDA $FD01
                        LDA     #$BD
                        STA     $5690
                        LEAX    EMERGENCY_JOYSCAN,PCR
                        STX     $5691

                        JMP     $5300

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

EMERGENCY_JOYSCAN       PSHS    B,X,Y,U,CC,DP
                        CLRA
                        BSR     JSRead

                        BITA    #JS_FLAG_ABUTTON
                        BNE     JOYSCAN_NO_ABUTTON
                        LDB     #$80
                        ORB     <$39
                        STB     <$39
JOYSCAN_NO_ABUTTON



                        TFR     A,B
                        ANDB    #JS_FLAG_LEFT+JS_FLAG_RIGHT+JS_FLAG_UP+JS_FLAG_DOWN
                        CMPB    #JS_FLAG_LEFT+JS_FLAG_RIGHT+JS_FLAG_UP+JS_FLAG_DOWN
                        BNE     JOYSCAN_DIRECTION_INPUT
                        CMPA    EMERGENCY_PREV_JS_STATE,PCR
                        BEQ     EMERGENCY_JOYSCAN_NOJSINPUT

JOYSCAN_DIRECTION_INPUT
                        LDB     #'0'        ; Tentative.  Stop


                        BITA    #JS_FLAG_LEFT
                        BNE     JOYSCAN_NOT_LEFT
                        LDB     #'7'
                        BRA     EMERGENCY_JOYSCAN_JSINPUT
JOYSCAN_NOT_LEFT

                        BITA    #JS_FLAG_RIGHT
                        BNE     JOYSCAN_NOT_RIGHT
                        LDB     #'9'
                        BRA     EMERGENCY_JOYSCAN_JSINPUT
JOYSCAN_NOT_RIGHT

                        BITA    #JS_FLAG_UP
                        BNE     JOYSCAN_NOT_UP
                        LDB     #'8'
                        BRA     EMERGENCY_JOYSCAN_JSINPUT
JOYSCAN_NOT_UP

                        BITA    #JS_FLAG_DOWN
                        BNE     JOYSCAN_NOT_DOWN
                        LDB     #'2'
                        BRA     EMERGENCY_JOYSCAN_JSINPUT
JOYSCAN_NOT_DOWN


EMERGENCY_JOYSCAN_JSINPUT
                        STA     EMERGENCY_PREV_JS_STATE,PCR
                        TFR     B,A
                        PULS    B,X,Y,U,CC,DP,PC


EMERGENCY_JOYSCAN_NOJSINPUT
                        LDA     $FD01
                        PULS    B,X,Y,U,CC,DP,PC

EMERGENCY_PREV_JS_STATE FCB     0

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


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

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

LAST_JOYSTICK_STATUS    FCB     0

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

SUBSYS_CMD              FCB     0,0
                        FCB     $3F     ; SubCPU Control
                        FCB     "YAMAUCHI"
                        FCB     $91
                        FDB     $D380+(SUBCPU_HOOK_BEGIN-SUBSYS_CMD)
                        FDB     $C900
                        FDB     #SUBCPU_HOOK_END-SUBCPU_HOOK_BEGIN
                        FCB     $90

SUBCPU_HOOK_BEGIN
                        LDA     $D401
                        STA     $C8FF
                        LDA     $D380
                        BPL     NO_MISSILE_FROM_MAINCPU
                        LDA     #1
                        STA     <$04
                        LDA     #$20
                        STA     $C8FF
NO_MISSILE_FROM_MAINCPU
                        LDA     <$04
                        CLR     $D381
                        RTS
SUBCPU_HOOK_END
SUBSYS_CMD_END

 

Comments are welcome.  Send E-Mail to: 

Back to http://www.ysflight.com