Author Topic: Barbarian 128k  (Read 15361 times)

0 Members and 1 Guest are viewing this topic.

Offline Devilmarkus

  • Vivid source of indefiniteness
  • 6128 Plus
  • ******
  • Posts: 4.035
  • Country: de
  • WebCPC / JavaCPC developer
    • index.php?action=treasury
    • CPC-Live website
    • Awards
Barbarian 128k
« on: 13:31, 28 October 13 »
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)
like
0
No reactions
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

Offline Devilmarkus

  • Vivid source of indefiniteness
  • 6128 Plus
  • ******
  • Posts: 4.035
  • Country: de
  • WebCPC / JavaCPC developer
    • index.php?action=treasury
    • CPC-Live website
    • Awards
Re: Barbarian 128k
« Reply #1 on: 14:12, 28 October 13 »
Added the missing princess to scene 3:

like
0
No reactions
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

Offline redbox

  • Supporter
  • 6128 Plus
  • *
  • Posts: 1.793
  • Country: gb
    • redbox
    • Awards
Re: Barbarian 128k
« Reply #2 on: 14:39, 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  ;)
like
0
No reactions

Offline Devilmarkus

  • Vivid source of indefiniteness
  • 6128 Plus
  • ******
  • Posts: 4.035
  • Country: de
  • WebCPC / JavaCPC developer
    • index.php?action=treasury
    • CPC-Live website
    • Awards
Re: Barbarian 128k
« Reply #3 on: 14:59, 28 October 13 »
As you wish:

Code infront the gamecode:

Code: [Select]
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:
Code: [Select]
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
« Last Edit: 15:06, 28 October 13 by Devilmarkus »
like
0
No reactions
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

Offline Axelay

  • 6128 Plus
  • ******
  • Posts: 597
  • Country: au
    • Awards
Re: Barbarian 128k
« Reply #4 on: 15:03, 28 October 13 »
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:
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?
like
0
No reactions

Offline Kris

  • 6128 Plus
  • ******
  • Posts: 589
  • Country: fr
  • Team Impact
    • Awards
Re: Barbarian 128k
« Reply #5 on: 15:06, 28 October 13 »
Really impressive job already done  :o , hope you will find some help here.....
like
0
No reactions

Offline Devilmarkus

  • Vivid source of indefiniteness
  • 6128 Plus
  • ******
  • Posts: 4.035
  • Country: de
  • WebCPC / JavaCPC developer
    • index.php?action=treasury
    • CPC-Live website
    • Awards
Re: Barbarian 128k
« Reply #6 on: 15:06, 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 :)
like
0
No reactions
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

Offline Devilmarkus

  • Vivid source of indefiniteness
  • 6128 Plus
  • ******
  • Posts: 4.035
  • Country: de
  • WebCPC / JavaCPC developer
    • index.php?action=treasury
    • CPC-Live website
    • Awards
Re: Barbarian 128k
« Reply #7 on: 15:07, 28 October 13 »
Playable work in progress:
RUN"BARBAR"


Edit: Updated DSK
« Last Edit: 15:27, 28 October 13 by Devilmarkus »
like
0
No reactions
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

Offline Kris

  • 6128 Plus
  • ******
  • Posts: 589
  • Country: fr
  • Team Impact
    • Awards
Re: Barbarian 128k
« Reply #8 on: 15:10, 28 October 13 »
Will test it this evening on real machine ;)
like
0
No reactions

Offline Devilmarkus

  • Vivid source of indefiniteness
  • 6128 Plus
  • ******
  • Posts: 4.035
  • Country: de
  • WebCPC / JavaCPC developer
    • index.php?action=treasury
    • CPC-Live website
    • Awards
Re: Barbarian 128k
« Reply #9 on: 15:21, 28 October 13 »
Fixed the princess's position:

I updated the DSK here!!!

« Last Edit: 15:28, 28 October 13 by Devilmarkus »
like
0
No reactions
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

Offline Axelay

  • 6128 Plus
  • ******
  • Posts: 597
  • Country: au
    • Awards
Re: Barbarian 128k
« Reply #10 on: 15:50, 28 October 13 »
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.  :-\
« Last Edit: 15:53, 28 October 13 by Axelay »
like
0
No reactions

Offline Devilmarkus

  • Vivid source of indefiniteness
  • 6128 Plus
  • ******
  • Posts: 4.035
  • Country: de
  • WebCPC / JavaCPC developer
    • index.php?action=treasury
    • CPC-Live website
    • Awards
Re: Barbarian 128k
« Reply #11 on: 15:52, 28 October 13 »
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...
like
0
No reactions
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

Offline Axelay

  • 6128 Plus
  • ******
  • Posts: 597
  • Country: au
    • Awards
Re: Barbarian 128k
« Reply #12 on: 16:23, 28 October 13 »
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.
like
0
No reactions

Offline Devilmarkus

  • Vivid source of indefiniteness
  • 6128 Plus
  • ******
  • Posts: 4.035
  • Country: de
  • WebCPC / JavaCPC developer
    • index.php?action=treasury
    • CPC-Live website
    • Awards
Re: Barbarian 128k
« Reply #13 on: 16:24, 28 October 13 »
LDI also needs more space I think...
like
0
No reactions
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

Offline arnoldemu

  • Supporter
  • 6128 Plus
  • *
  • Posts: 5.336
  • Country: gb
    • Unofficial Amstrad WWW Resource
    • Awards
Re: Barbarian 128k
« Reply #14 on: 17: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?




like
0
No reactions
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Offline beaker

  • 6128 Plus
  • ******
  • Posts: 810
  • Country: ie
  • Terrible at soldering...
    • index.php?action=treasury
    • Awards
Re: Barbarian 128k
« Reply #15 on: 18:00, 28 October 13 »
Nice, is there any way of giving the other sprites more colours? They always looked a little flat compared to the Goblin IMO.
like
0
No reactions

Offline STE86

  • CPC664
  • ***
  • Posts: 84
  • Country: gb
    • Awards
Re: Barbarian 128k
« Reply #16 on: 18:03, 28 October 13 »
exactly what I was thinking. are the sprites colour limited? and can the backgrounds be replaced?
like
0
No reactions

Offline Devilmarkus

  • Vivid source of indefiniteness
  • 6128 Plus
  • ******
  • Posts: 4.035
  • Country: de
  • WebCPC / JavaCPC developer
    • index.php?action=treasury
    • CPC-Live website
    • Awards
Re: Barbarian 128k
« Reply #17 on: 19:28, 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.
like
0
No reactions
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

Offline Gryzor

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 17.118
  • Country: gr
  • CPC-Wiki maintainer
    • CPCWiki
    • Awards
Re: Barbarian 128k
« Reply #18 on: 19:40, 28 October 13 »
...in-game music? :D
like
0
No reactions

Offline Devilmarkus

  • Vivid source of indefiniteness
  • 6128 Plus
  • ******
  • Posts: 4.035
  • Country: de
  • WebCPC / JavaCPC developer
    • index.php?action=treasury
    • CPC-Live website
    • Awards
Re: Barbarian 128k
« Reply #19 on: 20:02, 28 October 13 »
...in-game music? :D

Barbarian already has in-game music. Just press F2 during playing...
like
0
No reactions
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

Offline Gryzor

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 17.118
  • Country: gr
  • CPC-Wiki maintainer
    • CPCWiki
    • Awards
Re: Barbarian 128k
« Reply #20 on: 20:05, 28 October 13 »
*facepalm*


I had totally forgotten about that, but I mean with the sfx...
like
0
No reactions

Offline Devilmarkus

  • Vivid source of indefiniteness
  • 6128 Plus
  • ******
  • Posts: 4.035
  • Country: de
  • WebCPC / JavaCPC developer
    • index.php?action=treasury
    • CPC-Live website
    • Awards
Re: Barbarian 128k
« Reply #21 on: 20:11, 28 October 13 »
I mean with the sfx...

3 channels music + 3 channels sfx?

Ask TotO ;)
like
0
No reactions
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

Offline Gryzor

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 17.118
  • Country: gr
  • CPC-Wiki maintainer
    • CPCWiki
    • Awards
Re: Barbarian 128k
« Reply #22 on: 20:13, 28 October 13 »
Is the sfx really 3 channels? Wow, can't hear it.
like
0
No reactions

Offline Devilmarkus

  • Vivid source of indefiniteness
  • 6128 Plus
  • ******
  • Posts: 4.035
  • Country: de
  • WebCPC / JavaCPC developer
    • index.php?action=treasury
    • CPC-Live website
    • Awards
Re: Barbarian 128k
« Reply #23 on: 20:14, 28 October 13 »
At least 2 channels. Sometimes you can hear 2 "samples" @ the same time...
like
0
No reactions
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

Offline Gryzor

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 17.118
  • Country: gr
  • CPC-Wiki maintainer
    • CPCWiki
    • Awards
Re: Barbarian 128k
« Reply #24 on: 20:17, 28 October 13 »
Well ok, these two channels could take precedence over the tune... Really not sure how possible it is...
like
0
No reactions