BTII - Engine Subroutines & Variables (INCOMPLETE)
Posted: Sun Jan 17, 2021 7:28 pm
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.
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.