News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_Devilmarkus

Barbarian 128k

Started by Devilmarkus, 12:31, 28 October 13

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Devilmarkus

Did you like Barbarian from Palace Software?

But were you disappointed about the CPC-"limitations"?

For me, the most annoying limiatation was, that you have to select a scene on startup.

So I begun fiddling on a 128k version of the game, which pre-loads all 4 scenes, and checks, which opponent is actually fighting.

For this I disassembled the game, and patched a CALL xxxx to jump to my routine(s) instead of the old CALL.

In the routine I check:
- Store the required registers
- Actual opponent number (0-7)
- Select background scene for actual opponent (You have 8 opponents, and 4 backgrounds, so the result is: every 2nd opponent the background changes)
- Fix background's palette (Scene 1 has a slight different palette than scene 2,3 and 4)
- Write HUD (Scores, "MODE" message and the red life-points) into buffered background
- Write some variables from unseen screen ram into buffered background
- Write area of buffer background into the game's doublebuffer
- Bring buffered background to front
- Restore the registers
- CALL the original address (which should be called in the original CALL I replaced)

Most problematic here:
- I had to split the code: A part is before the original gamecode, and the other after the original gamecode
- Very limited memory space (The game stores variables etc... almost everywhere in ram)
- The routine is a bit slow, so the music stucks a little. Perhaps someone could optimize my routines? :D

Todo:
- Compress the bullshit
- Spread the game

Preview:
Erstellt von Camtasia Studio 8
(Heavily cheated, just to demonstrate it)
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Devilmarkus

Added the missing princess to scene 3:

When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

redbox

Quote from: Devilmarkus on 12:31, 28 October 13
- The routine is a bit slow, so the music stucks a little. Perhaps someone could optimize my routines? :D

If you post it here we can take a look at it  ;)

Devilmarkus

#3
As you wish:

Code infront the gamecode:

setbackground:
        di                    ;; disable interrupts and store registers
        push        bc
        push        de
        push        hl
        ex        af,af'
detectopponent:                ;; let's see in hidden screenram, which opponent is it
        ld        a,(&c7ed)
        cp        2
        jr        c,bank1
        cp        4
        jr        c,bank2
        cp        6
        jr        c,bank3
bank4:
        ld        a,&c7
        jp        setbank
bank3:
        ld        a,&c6
        jp        setbank
bank2:
        ld        a,&c5
        jp        setbank
bank1:
        ld        a,&c4
setbank:
        LD        B,&7F
        OUT        (C),a
       
        call        color        ;; let's patch the palette

copyscores:                    ;; copies the scores displayed into buffered image
        LD        DE,&49a8
        LD        HL,&c9a8
loopx:
        push        DE
        push        HL
        LD        BC,&20
        ldir
        pop        HL
        pop        DE
        ld        A,&08
        add        D
        ld        D,A
        ld        A,&08
        add        H
        ld        H,A
        cp        &01
        jr        nz,loopx

copymode:                    ;; copies the lower info (MODE 1, MODE 2, DEMO) from screen to buffered image
        LD        DE,&47a2
        LD        HL,&c7a2
loopz:
        push        DE
        push        HL
        LD        BC,12
        ldir
        pop        HL
        pop        DE
        ld        A,&08
        add        D
        ld        D,A
        ld        A,&08
        add        H
        ld        H,A
        cp        &07
        jr        nz,loopz

copyvariables:                ;; copy the variables from hidden screen ram to buffered image
        LD        DE,&47d0
        LD        HL,&c7d0
        LD        BC,&47
        ldir
        LD        DE,&4fd0
        LD        HL,&cfd0
        LD        BC,&47
        ldir

copytofront:                    ;; copy buffered image to screen
        LD        DE,&c000
        LD        HL,&4000
        LD        BC,&4000
        LDIR
        LD        Bc,&7Fc0
        OUT        (C),c
       
copytodoublebuffer:            ;; copy screen area to doublebuffer
        call        &7ddd

restoreregisters:                ;; restore the registers and re-enable the interrupts
        ex        af,af'
        pop        hl
        pop        de
        pop        bc
        ei
originalcall:                    ;; do the original CALL, the game wanted to do
        CALL        &7D0E
        RET


Code after gamecode:
color:
        ld        bc,&7f00+&4
        out        (c),c
        ld        a,(&c7ed)
        cp        2
        jr        c,color1
color0:
        ld        c,&58
        jp        setcol
color1:
        ld        c,&57
setcol:
        out        (c),c

                                ;; copy the red power dots to buffered image
        LD        DE,&4000
        LD        HL,&c000
loopy:
        push        DE
        push        HL
        LD        BC,&50
        ldir
        pop        HL
        pop        DE
        ld        A,&08
        add        D
        ld        D,A
        ld        A,&08
        add        H
        ld        H,A
        cp        &0
        jr        nz,loopy

        LD        DE,&4050
        LD        HL,&c050
loopt:
        push        DE
        push        HL
        LD        BC,&50
        ldir
        pop        HL
        pop        DE
        ld        A,&08
        add        D
        ld        D,A
        ld        A,&08
        add        H
        ld        H,A
        cp        &0
        jr        nz,loopt
        ret


Important:
Optimized code may have max. the length of the original code I posted here.

Bigger code makes the game crash!

Edit: fixed a bug in upper code
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Axelay

This is ... remarkable!  Believe it or not, I actually had a brief look into doing this not two weeks ago, as this was my favourite 1-on-1 fighter on the CPC.  Though I was thinking to do it as a ROM version that would still be compatible with 64K, but it became apparent it was going to take more time than I had to spare on it, let alone more ROMs for the time being.  Having to map in the ROM with the backgrounds on top of the screen where it needed to go looked like making things complicated with how much memory it uses.  And now you've done this!  :)


One thing:
Quote from: Devilmarkus on 13:12, 28 October 13
Added the missing princess to scene 3:


It looks like the princess is floating halfway above a step there, maybe move here down 4 pixels?

Kris

Really impressive job already done  :o , hope you will find some help here.....

Devilmarkus

Quote from: Axelay on 14:03, 28 October 13
One thing:
It looks like the princess is floating halfway above a step there, maybe move here down 4 pixels?

I tried to, but then it looks more worse, believe me :)
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Devilmarkus

#7
Playable work in progress:
RUN"BARBAR"


Edit: Updated DSK
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Kris

Will test it this evening on real machine ;)

Devilmarkus

#9
Fixed the princess's position:

I updated the DSK here!!!
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Axelay

#10
I dont think there's any getting around the delay on the music if you disable interrupts the whole time you copy the screen.  Do the interrupts really need to be disabled for the whole screen copy process?  Or was there something in particular that causes the problem you can just di/ei either side of?


For memory being a problem, could you, instead of copying the red dots from the top of the visible screen to the new background and copying the whole thing back, copy everything but the top two lines from the new background to the visible screen so the dots remain untouched, and if memory is a problem, you could use those top two lines of the background screens in the extended RAM for code, with each of the backgrounds in extended RAM having the same code in the same place?


EDIT:  Just remembered the interrupt routine itself sits inside the &4000-&7fff bank.  Well there goes that idea.  :-\

Devilmarkus

The dots are just 16 screenlines...
This won't cause any noticable speedup... (sadly)

As long the ram bank is swapped, I need to disable the interrupts, yes...
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Axelay

Well I guess further to that suggestion I made to cut down on the top two lines of copying, you could then use those two lines to copy with an unrolled string of ldi instructions rather than the single ldir, but that'll only be about 1/6 faster still.

Devilmarkus

LDI also needs more space I think...
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

arnoldemu

First, I like that you have all the backgrounds stored in this 128k version.

But I have a question:

In the game, the background is stored in ram like a sprite (I think).

So in the 128k version, you can just replace this sprite and then all works ok?

No need to save the health, scores etc?

or am I wrong?

I too was thinking of doing the same idea (all backgrounds in ram/rom).

But also I was going to change it so that it shows a menu instead of changing with "mode 1" and "mode 2", because I wanted to support other joysticks and make it easy to control on gx4000/6128plus with joystick only.

Any plans to have the high-score table or other things like this?




My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

beaker

Nice, is there any way of giving the other sprites more colours? They always looked a little flat compared to the Goblin IMO.

STE86

exactly what I was thinking. are the sprites colour limited? and can the backgrounds be replaced?

Devilmarkus

Quote from: arnoldemu on 16:52, 28 October 13
First, I like that you have all the backgrounds stored in this 128k version.

But I have a question:

In the game, the background is stored in ram like a sprite (I think).

So in the 128k version, you can just replace this sprite and then all works ok?

No need to save the health, scores etc?

or am I wrong?

I too was thinking of doing the same idea (all backgrounds in ram/rom).

But also I was going to change it so that it shows a menu instead of changing with "mode 1" and "mode 2", because I wanted to support other joysticks and make it easy to control on gx4000/6128plus with joystick only.

Any plans to have the high-score table or other things like this?

All 4 backgrounds are stored as 16k binaries.
I do like this:
- Copy GUI (scores, MODE display etc...) to buffered background @ given rambank (c4,c5,c6,c7)
- Copy some variables from unseen screenram (C7D0, E7D0) to buffered background
- Copy 16k screen (bufferedbackground) to front
- The game itself has a CALL &7DDD -> this copies the needed area (playfield) into the game's double buffer. This I also call here now, to copy from screen to game doublebuffer.

You can see that in my source code here:
Barbarian 128k


It makes no sense to have smaller screens, as the snakes also appear different in each scene. (Sure, to spare some ram, this could be a solution, but then every scene would have the same snakes @ border)

I don't plan anything else, the sprites are very cut into small snippets, so it makes no fun to edit them.

The game itself is only patched by replacing a CALL &7D0E (somewhere in gamecode) against a CALL setbackground.
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Gryzor


Devilmarkus

Quote from: Gryzor on 18:40, 28 October 13
...in-game music? :D

Barbarian already has in-game music. Just press F2 during playing...
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Gryzor

*facepalm*


I had totally forgotten about that, but I mean with the sfx...

Devilmarkus

Quote from: Gryzor on 19:05, 28 October 13
I mean with the sfx...

3 channels music + 3 channels sfx?

Ask TotO ;)
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Gryzor

Is the sfx really 3 channels? Wow, can't hear it.

Devilmarkus

At least 2 channels. Sometimes you can hear 2 "samples" @ the same time...
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

Gryzor

Well ok, these two channels could take precedence over the tune... Really not sure how possible it is...

Powered by SMFPacks Menu Editor Mod