News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_pmeier

Ghosts'n'Goblins two buttons hack

Started by pmeier, 17:04, 28 May 20

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

pmeier

Hi folks,
one of my favorite games is Ghosts'n'Goblins. Too bad it didn't support two button joysticks.
But yesterday I managed to apply a patch!  8) Now you can jump even right in front of a ladder!
Just as it was supposed to be!
I also added a simple menu to activate some cheats.

The patch does not just remap keys, I had to inject some code. The source is also included on the disk.
I'm not a Z80 expert, so I'm very proud that it worked.
Thanks to @Phantomz for giving me some hints.

org #1000

;; Ghosts'n'Goblins hack:
;; joy0-fire-2 to jump
;; joy0-up for climbing up ladders

;; USAGE
;; load Ghosts'n'Goblins
;; then assemble this file (WinAPE)

;; NOTES
;; I noticed that at #8f5c the zero flag is set if the player is in front of a ladder and will start climbing
;; otherwise he's not and jumps.
;; So I had just to add a routine to detect if joy up is pressed.

;; PSEUDO CODE (to inject at #8f5c)
;; if joy up, then #8f86 (start climbing up ladder)
;; else #8f5e (jump even at a ladder)

check_joy_up

        call keyscan

;; check if joy up is pressed
;; according to scancode table it's line 9, bit 0
        ld a,(keymap+9) ; line 9
        bit 0,a         ; bit 0 (bit=0 key is pressed)
        ret z           ; player will climb

        ld a,(#a607)    ; moved line here from original #8f5e (not enough space to leave instruction in place)
        ret             ; player will jump

;; http://www.cpcwiki.eu/index.php/Programming:Keyboard_scanning

keyscan di              ;1 ##%%## C P C   VERSION ##%%##
        ld hl,keymap    ;3
        ld bc,#f782     ;3
        out (c),c       ;4
        ld bc,#f40e     ;3
        ld e,b          ;1
        out (c),c       ;4
        ld bc,#f6c0     ;3
        ld d,b          ;1
        out (c),c       ;4
        ld c,0          ;2
        out (c),c       ;4
        ld bc,#f792     ;3
        out (c),c       ;4
        ld a,#40        ;2
        ld c,#4a        ;2 44
loop    ld b,d          ;1
        out (c),a       ;4 select line
        ld b,e          ;1
        ini             ;5 read bits and write into KEYMAP
        inc a           ;1
        cp c            ;1
        jr c,loop       ;2/3 9*16+1*15=159
        ld bc,#f782     ;3
        out (c),c       ;4
        ei              ;1 8 =211 microseconds
        ret

keymap  ds 10  ;map with 10*8 = 80 key status bits (bit=0 key is pressed)

;; original code I had to replace with call check_joy_up
;org #8f5c
;jr z,#8f86   ; 28 28
;ld a,(#a607) ; 3a 07 a6

;; replaced code (enable two button hack)
org #8f5c
call check_joy_up ; cd 00 10
; zero flag is only set if joy is up
jr z,#8f86        ; 28 25

;; replace keyboard button up 'Q' with 'joy0-fire-2'
;; (playing with keyboard is not longer possible!)
org #586b
db #00,#09,#20

;; inscrease highscores, so that it's impossible to reach keyboard dialog
org #5537
defb "9999999"
org #5548
defb "9999999"
org #5559
defb "9999999"
org #556A
defb "9999999"
org #557B
defb "9999999"
org #558C
defb "9999999"
org #559D
defb "9999999"
org #55AE
defb "9999999"
org #55BF
defb "9999999"
org #55D0
defb "9999999"

DanyPPC

CPC 464 with USB Floppy Emulator / CPC 464+ with USB Floppy Emulator / CPC 6128+ with C4CPC and Gotek HxC USB Drive Emulator

Phantomz


||C|-|E||

Very cool! I always liked G&G for the CPC, despite its obvious flaws. I it a shame, because everything is basically there in terms of game engine and level design, and with some more polishing it could had been truly great.

pmeier

Fixed version for 464.
My start menu previously used some string concatenation, but only if you change the start level. Then the start screen will be messed up (464/6128) and on 464 it crashes after game over. I noticed that after copying to my real 464, but WinAPE behaves the same.

If wish I knew the details about that. Where is the memory dumped? Why does GNG care about it...Back in the days I wasn't aware that the @ operator shows the address of a string.


pmeier

New version!

I added @Jean-Marie 's undressed edition v1.1! Thank you!

My "jump in front of a ladder" patch now uses the game's joystick routine. Previously I added an additional scanning routine. Should now be faster. Although I don't notice it.

Anthony Flack

On the subject, how hard do you think it would be to hack it so you can turn around and shoot behind you when you're in mid-air? (as it should be). Randomising the zombie spawn points would help a lot too, rather than endlessly spawning from the same grave...

Just a thought. I also have a soft spot for Amstrad GnG despite its many shortcomings, with its smooth full-screen graphics, big Ste Pickford sprites and extremely rocking music. It seems like with a couple more weeks of work it could have been a whole different game. 

TotO

G&W was fun to play. Copy with wrong design was more Tiger.
"You make one mistake in your life and the internet will never let you live it down" (Keith Goodyer)

Ace

Quote from: Anthony Flack on 03:24, 24 April 23how hard do you think it would be to hack it so you can turn around and shoot behind you when you're in mid-air?
This!

Also is it posible to take care of the 'faulty' behavior that Arthur tries to climb a ladder even if there isn't one? I 've lost too many lives 'locked up' in the climb position unable to shoot, whenever I accidentally pressed up.

pmeier

Quote from: Anthony Flack on 03:24, 24 April 23On the subject, how hard do you think it would be to hack it so you can turn around and shoot behind you when you're in mid-air? (as it should be). Randomising the zombie spawn points would help a lot too, rather than endlessly spawning from the same grave...
Too hard for me! But if there is anybody out there who can: Could you please also make a level editor ;D

pmeier

Quote from: Ace on 11:21, 24 April 23Also is it posible to take care of the 'faulty' behavior that Arthur tries to climb a ladder even if there isn't one? I 've lost too many lives 'locked up' in the climb position unable to shoot, whenever I accidentally pressed up.
He he, I tried, but trying took longer that the whole patch... so I gave up...

Powered by SMFPacks Menu Editor Mod