Citadel Disassembly / Reassembly v0.1

reminisce about bbc micro & electron games like chuckie egg, repton, elite & exileRelated forum: adventures


Post Reply
Diminished
Posts: 116
Joined: Fri Dec 08, 2017 9:47 pm
Contact:

Citadel Disassembly / Reassembly v0.1

Post by Diminished » Mon Oct 08, 2018 3:43 pm

Roll Your Own Citadel:
citadel-reassembly-0.1-rc4.zip
(54.65 KiB) Downloaded 43 times
Here's the README:

Code: Select all

Citadel BBC Reassembly
v0.1, 8th October 2018

Original game by Michael Jakobsen
Disassembly / reassembly by 'Diminished'

---

INTRO
  This is a set of files -- including reverse-engineered source code  -- that
  will enable you to build a Model B version of Citadel.

YOU WILL NEED
  - BeebAsm (http://www.retrosoftware.co.uk/wiki/index.php?title=BeebAsm)

FILES
  - 6502 source:
    - citadel.asm   main source file; assembly directives are in here (D_*)
    - consts.asm    most of the constants (C_*); chained by citadel.asm
    - vars.asm      memory locations of variables and tables; chained by
                    citadel.asm
    - shim.asm      short move-down routine and final initialisation code;
                    chained by citadel.asm
                    
  - BASIC source:
    - loader.bas    the BBC BASIC loader used to launch the game
    
  - Data:
    These are pure data files and no code resides in them, although certain
    parts of x740.bin encompass regions which are used by the game as
    variables.
    - x600-f.bin    female player sprite data residing at &600 (320 bytes)
    - x600-m.bin    male player sprite data residing at &600 (320 bytes)
    - x740.bin      main data file; mostly room/tile data and room names,
                    starting at &740 (7,616 bytes)
    
  - Others:
    - template.ssd  a BBC disc image used by BeebAsm as a template; it contains
                    a single file called JEZEBEL, which is just a Beeb-native
                    copy of loader.bas
    - build.sh      a bash script which may be used to build the game
  
BUILDING IT
  Simply:
  
    beebasm -i citadel.asm -do jezebel.ssd -di template.ssd -v
  
  which will create a disc image called jezebel.ssd with everything you need
  to run your newly minted game. Put the image somewhere appropriate, and then
  CHAIN "JEZEBEL" to load the game.
  
  If you are building on a system with bash, you can use the provided build.sh
  to build the game. You may need to edit the file so the correct path to
  BeebAsm is specified.
  
  If you are looking for things to modify, consts.asm is definitely the place
  to begin, along with the directives (D_*) at the top of citadel.asm.
  
BUGS
  - picking up the very first energy flask in the game emits the wrong sound
    effect

OTHER ISSUES
  There are some problems with relocating pieces of code. In particular,
  if you are building a non-retail version (D_RETAIL = 0) with a keyboard
  control scheme (D_CONTROL_SCHEME < 4) it ought to be possible to 
  reclaim the bytes before the keyboard map (T_KEYMAP) that are usually
  reserved for the absent and slightly larger joystick routine. However,
  reassembling all the code north of this point at a lower address causes
  serious player sprite corruption, and the reason is currently unknown. Note
  that this bug seems to persist even using an (emulated) CMOS 6502 which
  lacks the JSR page boundary bug, which I originally suspected to be the
  culprit. The D_NON_RETAIL_PADDING_BEFORE_KEYMAP flag exists for this reason
  and should be set to 1 for non-retail builds to ensure that the unused
  joystick routine bytes are reserved as in the retail versions.
  
  Disassembly / reassembly is a work in progress, so some variables and
  routines are still poorly labelled and understood, and mistakes are likely.
  
  There is currently no Master 128 support; you can only use this to build for
  the Model B.

ABOUT THE LOADER
  I wanted the simplest possible loader setup, without the need for arcane
  assembly language initialisation routines and multi-stage relocations.
  So JEZEBEL (a.k.a. loader.bas) changes to MODE 2 straight away, and sets up
  nearly all of the OS and CRTC parameters needed by the game right there in
  BASIC. It then disables the cursor and performs a *OPT 1,0 to suppress any
  filing system messages, before quite happily loading 16K of 400IMG plus the
  small move-down/final initialisation shim into "live" video RAM. This
  simplifies everything greatly, but has the disadvantage that any filing
  system errors (particularly cassette filing system errors) will not be
  reported to the user.
  
  The only functions performed by SHIM, the tiny piece of 6502 initialisation
  code, are moving down the main code to &400, setting up the stack
  and enabling the OS vector that allows the game to react to vertical sync.
  
  The run-time patching performed by the game's retail loader for choosing
  the gender of the player sprite and the control method has also been
  simplified out of this implementation. Player sprite and control scheme
  selection are implemented here as traditional conditional assembly
  language directives (in consts.asm), so if you want to support all ten
  combinations (five control schemes and two genders) then you will need to
  assemble the game ten times.
Bonus tape UEF image containing a reassembled game. No control scheme selection, title screen, gender selection or complicated loader means that this ought to be the fastest way to load the game from tape (although it still suffers from the flask audio bug mentioned above, so not quite perfect):
jez.uef
(21.03 KiB) Downloaded 13 times
Last edited by Diminished on Mon Oct 08, 2018 6:38 pm, edited 3 times in total.

User avatar
streaks
Posts: 262
Joined: Thu Oct 13, 2005 2:08 pm
Contact:

Re: Citadel Disassembly / Reassembly v0.1

Post by streaks » Wed Oct 10, 2018 7:05 pm

Insane
streaksy (at) gmail (dot) com

Diminished
Posts: 116
Joined: Fri Dec 08, 2017 9:47 pm
Contact:

Re: Citadel Disassembly / Reassembly v0.1

Post by Diminished » Wed Oct 10, 2018 9:00 pm

streaks wrote:
Wed Oct 10, 2018 7:05 pm
Insane
I'm inclined to agree

6502
Posts: 21
Joined: Sat Mar 17, 2018 1:04 pm
Location: London
Contact:

Re: Citadel Disassembly / Reassembly v0.1

Post by 6502 » Sun Oct 21, 2018 8:34 am

Anyone get the impression Diminished likes the game Citadel? :D

Great stuff, I'll have a play around with this when I get the chance.

Diminished
Posts: 116
Joined: Fri Dec 08, 2017 9:47 pm
Contact:

Re: Citadel Disassembly / Reassembly v0.1

Post by Diminished » Mon Oct 22, 2018 2:07 am

6502 wrote:
Sun Oct 21, 2018 8:34 am
Anyone get the impression Diminished likes the game Citadel? :D
Well, the number of people willing and able to undertake disassembly of old BBC games has to be pretty small at this point, and it's only going to get smaller. I still don't understand how parts of the game work, but publishing what I have done seems important because I doubt anybody else will ever bother.

To be honest, I had expected by now that someone would make a post in one of the Citadel threads along the lines of "I disassembled this back in '89 because it was raining one Saturday afternoon and I couldn't go skateboarding, here's the source code and full documentation of the data formats", but so far at least that hasn't happened.

6502
Posts: 21
Joined: Sat Mar 17, 2018 1:04 pm
Location: London
Contact:

Re: Citadel Disassembly / Reassembly v0.1

Post by 6502 » Mon Oct 22, 2018 12:44 pm

Diminished wrote:
Mon Oct 22, 2018 2:07 am
6502 wrote:
Sun Oct 21, 2018 8:34 am
Anyone get the impression Diminished likes the game Citadel? :D
Well, the number of people willing and able to undertake disassembly of old BBC games has to be pretty small at this point, and it's only going to get smaller. I still don't understand how parts of the game work, but publishing what I have done seems important because I doubt anybody else will ever bother.

To be honest, I had expected by now that someone would make a post in one of the Citadel threads along the lines of "I disassembled this back in '89 because it was raining one Saturday afternoon and I couldn't go skateboarding, here's the source code and full documentation of the data formats", but so far at least that hasn't happened.
Well keep up the good work.

Is your end goal to recreate Citadel with new screens, objects and puzzles?

Diminished
Posts: 116
Joined: Fri Dec 08, 2017 9:47 pm
Contact:

Re: Citadel Disassembly / Reassembly v0.1

Post by Diminished » Thu Oct 25, 2018 3:56 am

6502 wrote:
Mon Oct 22, 2018 12:44 pm
Diminished wrote:
Mon Oct 22, 2018 2:07 am
6502 wrote:
Sun Oct 21, 2018 8:34 am
Anyone get the impression Diminished likes the game Citadel? :D
Well, the number of people willing and able to undertake disassembly of old BBC games has to be pretty small at this point, and it's only going to get smaller. I still don't understand how parts of the game work, but publishing what I have done seems important because I doubt anybody else will ever bother.

To be honest, I had expected by now that someone would make a post in one of the Citadel threads along the lines of "I disassembled this back in '89 because it was raining one Saturday afternoon and I couldn't go skateboarding, here's the source code and full documentation of the data formats", but so far at least that hasn't happened.
Well keep up the good work.

Is your end goal to recreate Citadel with new screens, objects and puzzles?
I'm not sure if I have an end goal, really. It would be cool to publish a map editor.

In general I tend to publish things when I know I won't be working on them again for a little while, so this will probably be it for now.

User avatar
streaks
Posts: 262
Joined: Thu Oct 13, 2005 2:08 pm
Contact:

Re: Citadel Disassembly / Reassembly v0.1

Post by streaks » Thu Oct 25, 2018 6:59 am

During the update wave when you gave me the sprite images I felt like making a Citadel editor (for Windows, not the Beeb, but in Beeb style) and designed like half of a game map with updated graphics. Triangle cut-outs, background layer, overlay layer and stuff. I knew I'd not make a finished game out of it - it was something to do. Might post screenshots/video for the hell of it. I like my nerdy go-nowhere hobbies. I'm not imaginative enough to think of enough new Citadelish game objects and tasks but I came up with a few ideas, like carrying the torch lit the dark areas (like the candle in Palace of Magic), but there were braziers you could light by touching while holding the torch, so the room is lit forever after.
streaksy (at) gmail (dot) com

Diminished
Posts: 116
Joined: Fri Dec 08, 2017 9:47 pm
Contact:

Re: Citadel Disassembly / Reassembly v0.1

Post by Diminished » Sat Oct 27, 2018 5:44 pm

The torch thing isn't a bad idea!

I'm wondering where you might be able to find any extra RAM to expand the game. Not much is available, unless you cheat and use sideways RAM, which honestly might be the way to go.

Finding a way to compress the room names might be a place to start. You might save a hundred bytes that way.
Last edited by Diminished on Sat Oct 27, 2018 6:34 pm, edited 1 time in total.

User avatar
streaks
Posts: 262
Joined: Thu Oct 13, 2005 2:08 pm
Contact:

Re: Citadel Disassembly / Reassembly v0.1

Post by streaks » Sun Oct 28, 2018 10:32 pm

Think you would make an expanded Citadel for the beeb?
streaksy (at) gmail (dot) com

Diminished
Posts: 116
Joined: Fri Dec 08, 2017 9:47 pm
Contact:

Re: Citadel Disassembly / Reassembly v0.1

Post by Diminished » Mon Oct 29, 2018 5:04 pm

I'd say it's unlikely at this time.

6502
Posts: 21
Joined: Sat Mar 17, 2018 1:04 pm
Location: London
Contact:

Re: Citadel Disassembly / Reassembly v0.1

Post by 6502 » Sun Nov 04, 2018 11:59 pm

Have just finished changing the tile data raw bytes &0955 to &139F to beebasm assembly.
This makes viewing and changing the tile data much easier.
As the .asm file is quite long, I've decided to add it as a include file to citadel.asm.

Had trouble uploading these files as an attachment with this forum, so pasted them into filedropper website. I've posted the sha1 hash below each file, so you can check for tampering/corruption.

http://www.filedropper.com/x740-954
sha1sum b707e54eb4205d49f4bc2105d419f80713d0c6e5 x740-954.bin

http://www.filedropper.com/tiledatabytes
sha1sum 630d53611fa30aa358fc7486b92ce42cd513d9f7 tile_data_bytes.asm

http://www.filedropper.com/x13a0
sha1sum fb4bd871721db5255b9acc456ba7e04c4c675fdd x13a0.bin


The other raw bytes still need to be included into citadel.asm, which I have seperated and must be included each side of the asm file.
These 3 files need to go into the citadel folder where citadel.asm is.

Simply remove

Code: Select all

; 7.4K of (mostly) room/tile data and room names loaded at &740:
incbin "x740.bin"
line 98 in citadel.asm and replace with

Code: Select all

; 7.4K of (mostly) room/tile data and room names loaded at &740:
incbin "x740-954.bin"
include "tile_data_bytes.asm"
incbin "x13a0.bin"

Diminished
Posts: 116
Joined: Fri Dec 08, 2017 9:47 pm
Contact:

Re: Citadel Disassembly / Reassembly v0.1

Post by Diminished » Mon Nov 05, 2018 4:21 am

Cool. I'll integrate this when I get round to doing another release. I need to track down that relocation bug too, and I've improved some of the naming in my local copy.

I botched the README slightly last time as well (rushed the release a bit) but it didn't seem worth repackaging the whole thing just for that.

Thanks.
Last edited by Diminished on Mon Nov 05, 2018 4:40 am, edited 2 times in total.

Post Reply