BTII - Engine Subroutines & Variables (INCOMPLETE)

Any developer realated stuff
Post Reply
User avatar
Darendor
Posts: 1502
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

BTII - Engine Subroutines & Variables (INCOMPLETE)

Post by Darendor »

So I thought it'd be useful to post my (and others') partial findings of the game subroutines and variables and just what the heck they do.

Additions, corrections, and spaghetti are all welcome.

Code: Select all

$24: Party facing - 0 = N, 1 = E, 2 = S, 3 = W.
$28: The party's NORTH co-ordinate.
$29: The party's EAST co-ordinate.
$58: Low-byte pointer to caption text.	 Stored via LDA #$[byte].
$59: High-byte pointer to caption text.  Stored via LDA #$[byte].
  $JSR 080F is the subroutine for displaying the caption.
$9B: High byte of address for character data.
$9C: Low byte of address for character data.
$A8: Current city the party is in.
  00 = Wilderness
  01 = Tangramayne
  02 = Ephesus
  03 = Philippi
  04 = Colosse
  05 = Corinth
  06 = Thessalonica
	The APAR spell directly sets $00a8 to whatever "City #" is chosen...
$C1: Time pause?  0=no, 1 = yes
$D4: Disk to insert into drive: [INCONCLUSIVE]
  00: Character Disk
  01: Dungeon A
  02: Dungeon B ????
$E0: Offset byte for track/sector table, to find file to be loaded by $0899
$EB: Time of day
$F6: Is a bard playing? [1 = yes] [2-?: which bard song?]

      $0334 - $0342: Contains input buffer keyboard entry
  JSR $080C: jump => $0BF1 => scroll text window 1 line
  JSR $080F: Display caption; $59 has high byte of location; $58 has low byte of location
  JSR $0821: jump => $0F77 => check if character has enough gold
  JSR $0824: jump => $0F94 => substract price from character gold
  JSR $0830: Output price (output number?)
  JSR $0836: Prompt player for input from keyboard
  JSR $0848: jump => $11B3 => update character display
  JSR $081b: Load picture file?
  JSR $0851: View character # held in ACC
  JSR $086C: jump => $472D => update values of character
  JSR $0878: Get keypress
  JSR $0887: Evaluate/analyze key pressed?
  JSR $088D:jump => $1CC2 => key input, check if pressed key was valid (0-6) and load character address in Y and A
  JMP $0899: Load file from T/S as per $e0
  JMP $08c3: Executes "APAR" spell code
  JMP $08f6: Executes party death code
  JSR $08E1: Clear the text window.
  JSR $091A: jump => $1D77 => wait a time

$9a00: "Special event" location loaded from non-dungeon floors (i.e. city, Wilderness), a la Roscoe's, Garthe's, Dungeon Entrance, etc.
$a200: "Special event" location loaded from dungeon-only floors, a la Magic Mouth, etc.
drifting
Posts: 152
Joined: Wed Dec 07, 2011 10:21 pm

Re: BTII - Engine Subroutines & Variables (INCOMPLETE)

Post by drifting »

$0890 - Random number generator. Stores a random byte in $5A
User avatar
Darendor
Posts: 1502
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Re: BTII - Engine Subroutines & Variables (INCOMPLETE)

Post by Darendor »

A vital component of any AD&D-style game: Random dice rolls.

I wonder if you can set the variables to generate a number from X to Y, say...?
Weber G
Posts: 125
Joined: Tue Dec 15, 2020 9:58 am

Re: BTII - Engine Subroutines & Variables (INCOMPLETE)

Post by Weber G »

$0890 - Random number generator. Stores a random byte in $5A
and $5B
I wonder if you can set the variables to generate a number from X to Y, say...?
What you want. But it's a 8 bit system. So the random number is always between 0 and 255. If you want a lower number you can AND the result with a lower number.
User avatar
Darendor
Posts: 1502
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Re: BTII - Engine Subroutines & Variables (INCOMPLETE)

Post by Darendor »

Weber G wrote: Tue Jan 19, 2021 6:16 pm
$0890 - Random number generator. Stores a random byte in $5A
and $5B
I wonder if you can set the variables to generate a number from X to Y, say...?
What you want. But it's a 8 bit system. So the random number is always between 0 and 255. If you want a lower number you can AND the result with a lower number.
So if I understand this correctly, JSR $0890 generates a 2 byte random number and stores it in $5A and $5B, high and low byte?
Weber G
Posts: 125
Joined: Tue Dec 15, 2020 9:58 am

Re: BTII - Engine Subroutines & Variables (INCOMPLETE)

Post by Weber G »

No, not one 2 byte number, but two 1 byte numbers.
User avatar
Darendor
Posts: 1502
Joined: Wed Jan 14, 2009 1:53 am
Location: Red Deer, Alberta, Canada

Re: BTII - Engine Subroutines & Variables (INCOMPLETE)

Post by Darendor »

And they're different, I presume.
Post Reply