Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relative position of globals #1304

Open
AJenbo opened this issue Jul 11, 2019 · 3 comments
Open

Relative position of globals #1304

AJenbo opened this issue Jul 11, 2019 · 3 comments

Comments

@AJenbo
Copy link
Member

AJenbo commented Jul 11, 2019

On the topic of getting correct memory layout I think one place to start is correcting the relative order of the global variables. For me the biggest gap of knoleage is how the globals are positioned in the roginal exe. There is the documentation at https://github.com/sanctuary/notes but our naming is different so it would need some work and also I'm not really sure how best to pase the text format in order to sort them by memory address.

This appears to be the current order of our global variables:

fontframe
fontkern
lineoffset
gbFontTransTbl
InvItemWidth
InvItemHeight
SPATS
BSTYPES
L5BTYPES
STAIRSUP
L5STAIRSUP
STAIRSDOWN
LAMPS
PWATERIN
L3ConvTbl
L3UP
L3DOWN
L3HOLDWARP
L3TITE1
L3TITE2
L3TITE3
L3TITE6
L3TITE7
L3TITE8
L3TITE9
L3TITE10
L3TITE11
L3TITE12
L3TITE13
L3CREV1
L3CREV2
L3CREV3
L3CREV4
L3CREV5
L3CREV6
L3CREV7
L3CREV8
L3CREV9
L3CREV10
L3CREV11
L3ISLE1
L3ISLE2
L3ISLE3
L3ISLE4
L3ISLE5
L3XTRA1
L3XTRA2
L3XTRA3
L3XTRA4
L3XTRA5
L3ANVIL
L4ConvTbl
L4USTAIRS
L4TWARP
L4DSTAIRS
L4PENTA
L4PENTA2
L4BTYPES
monster_action_sounds
rand_increment
rand_multiplier
lfontframe
lfontkern
gszHelpText
progress_bar_colours
progress_bar_screen_pos
PL_Prefix
PL_Suffix
UniqueItemList
mfontframe
mfontkern
plr2monst
counsmiss
event_types
pathxdir
pathydir
ArmourChar
WepChar
CharChar
text_color_from_player_num
alltext
gdwAllTextEntries
_FInf
exception_c_init_funcs
SpellITbl
PanBtnPos
PanBtnHotKey
PanBtnStr
attribute_inc_rects
SpellPages
fullscreen
FriendlyMode
spszMsgTbl
spszMsgKeyTbl
L5ConvTbl
Area_Min
Room_Max
Room_Min
Dir_Xadd
Dir_Yadd
SPATSL2
BTYPESL2
BSTYPESL2
VARCH1
VARCH2
VARCH3
VARCH4
VARCH5
VARCH6
VARCH7
VARCH8
VARCH9
VARCH10
VARCH11
VARCH12
VARCH13
VARCH14
VARCH15
VARCH16
VARCH17
VARCH18
VARCH19
VARCH20
VARCH21
VARCH22
VARCH23
VARCH24
VARCH25
VARCH26
VARCH27
VARCH28
VARCH29
VARCH30
VARCH31
VARCH32
VARCH33
VARCH34
VARCH35
VARCH36
VARCH37
VARCH38
VARCH39
VARCH40
HARCH1
HARCH2
HARCH3
HARCH4
HARCH5
HARCH6
HARCH7
HARCH8
HARCH9
HARCH10
HARCH11
HARCH12
HARCH13
HARCH14
HARCH15
HARCH16
HARCH17
HARCH18
HARCH19
HARCH20
HARCH21
HARCH22
HARCH23
HARCH24
HARCH25
HARCH26
HARCH27
HARCH28
HARCH29
HARCH30
HARCH31
HARCH32
HARCH33
HARCH34
HARCH35
HARCH36
HARCH37
HARCH38
HARCH39
HARCH40
USTAIRS
DSTAIRS
WARPSTAIRS
CRUSHCOL
BIG1
BIG2
BIG3
BIG4
BIG5
BIG6
BIG7
BIG8
BIG9
BIG10
RUINS1
RUINS2
RUINS3
RUINS4
RUINS5
RUINS6
RUINS7
PANCREAS1
PANCREAS2
CTRDOOR1
CTRDOOR2
CTRDOOR3
CTRDOOR4
CTRDOOR5
CTRDOOR6
CTRDOOR7
CTRDOOR8
Patterns
sgSFX
MsgStrings
sgSingleMenu
sgMultiMenu
sgOptionMenu
music_toggle_names
sound_toggle_names
color_cycling_toggle_names
gszVersionNumber
gszProductName
AP2x2Tbl
AllItemsList
ItemCAnimTbl
ItemDropStrs
ItemAnimLs
ItemDropSnds
ItemInvSnds
idoppely
premiumlvladd
CrawlTable
pCrawlTable
vCrawlTable
byte_49463C
RadiusAdj
log_not_created
log_file
menu_music_track_id
qscroll_spd_tbl
missiledata
misfiledata
XDirAdd
YDirAdd
monsterdata
MonstConvTbl
MonstAvailTbl
UniqMonst
MWVel
animletter
left
right
opposite
offset_x
offset_y
rnd5
rnd10
rnd20
rnd60
AiProc
sghArchive
ObjTypeConv
AllObjects
ObjMasterLoadList
bxadd
byadd
shrinestrs
shrinemin
shrinemax
shrineavail
StoryBookName
StoryText
gamma_correction
color_cycling_enabled
sgbFadedIn
path_directions
plrxoff
plryoff
plrxoff2
plryoff2
PlrGFXAnimLens
PWVel
StrengthTbl
MagicTbl
DexterityTbl
VitalityTbl
ToBlkTbl
ClassStrTblOld
MaxStats
ExpLvlsTbl
ClassStrTbl
fix
WarpDropX
WarpDropY
questlist
questxoff
questyoff
questtrigstr
QuestGroup1
QuestGroup2
QuestGroup3
QuestGroup4
szMonModeAssert
szPlrModeAssert
SkelKingTrans1
SkelKingTrans2
SkelKingTrans3
SkelKingTrans4
SkelChamTrans1
SkelChamTrans2
SkelChamTrans3
quest_level_names
quest_level_names
gbMusicOn
gbSoundOn
gbDupSounds
sgnMusicTrack
sgszMusicTracks
unk_volume
spelldata
SStringY
talkname
ThemeGood
trm5x
trm5y
trm3x
trm3y
AnimOrder
TownCowX
TownCowY
TownCowDir
cowoffx
cowoffy
Qtalklist
CowPlaying
TownDownList
TownWarp1List
L1UpList
L1DownList
L2UpList
L2DownList
L2TWarpUpList
L3UpList
L3DownList
L3TWarpUpList
L4UpList
L4DownList
L4TWarpUpList
L4PentaList
RightMask
LeftMask
WallMask
WorldTbl3x16
WorldTbl17_1
WorldTbl17_2
cleanup_thread_id
sz_error_buf
terminating
AutoMapXOfs
AutoMapXPos
AutoMapScale
AutoMapYOfs
AMPlayerY
automaptype
AMPlayerX
AutoMapYPos
automapflag
automapview
AutoMapPosBits
AmShiftTab
sgbNextTalkSave
sgbTalkSavePos
pDurIcons
drawhpflag
pChrButtons
dropGoldFlag
SplTransTbl
nGoldFrame
panbtn
chrbtn
pMultiBtns
pPanelButtons
pChrPanel
lvlbtndown
dropGoldValue
drawmanaflag
sgszTalkMsg
pPanelText
spselflag
pLifeBuff
pBtmBuff
pstrjust
pTalkBtns
sgszTalkSave
pnumlines
pinfoflag
talkbtndown
pSpell
pManaBuff
infoclr
pGBoxBuff
pSBkBtnCel
tempstr
frame
sgbPlrTalkTbl
sbooktab
pSplType
initialDropGoldIndex
talkflag
pSBkIconCels
sbookflag
chrflag
drawbtnflag
pSpellBkCel
infostr
whisper
numpanbtns
pStatusPanel
panelstr
panelflag
initialDropGoldValue
pSpellCels
panbtndown
chrbtnactive
pTalkPanel
pcursmonst
cursH
icursH28
cursW
icursW28
pCursCels
icursH
icursW
pcursobj
pcurstemp
pcursplr
pcurs
pcursinvitem
pcursitem
cursmx
cursmy
spurtndx
dead
stonendx
seed_index
dMonsDbg
seed_table
level_seeds
dFlagDbg
pSquareCel
setseed
sgnTimeoutCurs
ghMainWnd
visiondebug
glMid1Seed
color_cycle_timer
glMid2Seed
gnLevelTypeTbl
MouseY
debugmonsttypes
MouseX
cineflag
sgbMouseDown
scrollflag
gbGameLoopStartup
glSeedTbl
monstdebug
gbRunGame
leveldebug
glMid3Seed
gbRunGameResult
trigdebug
gbProcessPlayers
PauseMode
drawpanflag
light4flag
glEndSeed
gbLoadGame
ghInst
zoomflag
DebugMonsters
doomflag
doom_stars_drawn
doom_quest_time
pDoomCel
DoomQuestState
L5dungeon
L5dflags
setloadflag
HR1
HR2
HR3
VR1
VR2
VR3
pSetPiece
nSx1
nSx2
nSy1
nSy2
nRoomCnt
predungeon
RoomList
pHallList
lavapool
abyssx
lockoutcnt
lockout
diabquad1x
diabquad1y
diabquad3x
diabquad3y
diabquad2x
diabquad2y
diabquad4x
diabquad4y
hallok
l4holdx
l4holdy
SP4x1
SP4x2
SP4y1
SP4y2
L4dungeon
dung
dthread_running
sgpInfoHead
sghWorkToDoEvent
glpDThreadId
sgpBackBuf
gbBackBuf
sgdwLockCount
gpBuffer
lpDDSBackBuf
lpDDSPrimary
lpDDInterface
lpDDPalette
ghDiabMod
gbEmulate
sfxdelay
sfxdnum
sfx_stream
sfx_data_cur
hashtable
orgseed
sgnWidth
gbNotInView
gbPixelCol
sglGameSeed
SeedCount
gbRotateMap
msgtable
msgdelay
msgflag
msgcnt
lpTopLevelExceptionFilter
fault_unused
themeCount
nTransTable
dMonster
dungeon
dObject
pSpeedCels
pdungeon
dDead
level_frame_sizes
dArch
TransVal
MicroTileLen
setloadflag_2
dflags
dPiece
dLight
tile_defs
pMegaTiles
block_lvid
gnDifficulty
dpiece_defs_map_2
dpiece_defs_map_1
dTransVal
pLevelPieces
nTrapTable
leveltype
currlevel
TransList
nSolidTable
pDungeonCels
ScrollInfo
dPlayer
themeLoc
pSetPiece_2
nBlockTable
pSpecialCels
SpeedFrameTbl
dFlags
dItem
setlvlnum
nMissileTable
nlevel_frames
level_frame_count
setlvltype
setlevel
dPreLight
dword_5C2FFC
LvlViewY
LvlViewX
dmaxx
dmaxy
setpc_h
scr_pix_height
dword_5C2FF8
setpc_w
setpc_x
ViewX
setpc_y
ViewY
dMissile
dminx
dminy
level_frame_types
scr_pix_width
option_cel
PentSpin_cel
BigTGold_cel
PentSpin_tick
sgCurrentMenuIdx
sgpCurrentMenu
dword_63447C
PentSpin_frame
mouseNavigation
sgpCurrItem
sgpLogo
optbar_cel
dword_634494
displayinghelp
helpflag
HelpTop
help_select_line
patch_rt_mpq_path
gbActive
diabdat_mpq
unused_mpq
fileinfo
CurrentProc
diablo_exe_path
diabdat_mpq_path
screensaver_enabled_prev
killed_mom_parent
patch_rt_mpq
sgpBackCel
sgdwProgress
progress_id
sgdwLastTime
invflag
pInvCels
drawsbarflag
itemactive
uitemflag
itemavail
itemrecord
curruitem
item
itemhold
gnNumGetRecords
itemanims
numitems
UniqueItemFlag
VisionList
lightactive
LightList
numlights
dovision
numvision
lightradius
lightblock
lightmax
lightflag
dolighting
visionid
pLightTbl
tbuff
log_buffer
nNumberOfBytesToWrite
lpAddress
FileName
gszHero
qtexty
qtextptr
sgLastScroll
qtextflag
scrolltexty
qtextSpd
pMedTextCels
pTextBoxCels
missileactive
chain
missileavail
missile
nummissiles
ManashieldFlag
numchains
MissilePreFlag
monstkills
monstactive
nummonsters
nummtypes
sgbSaveSoundOn
monster
totalmonsters
Monsters
monstimgtot
MissileFileFlag
uniquetrans
movie_playing
loop_movie
sgpHashTbl
save_archive_open
save_archive_modified
sgdwMpqOffset
mpq_buf
sgpBlockTbl
gbBufferMsgs
pkt_counter
deltaload
gbSomebodyWonGameKludge
sgHiPriBuf
sgwPackPlrOffsetTbl
sgbPlayerLeftGameTbl
sgbPlayerTurnBitTbl
szPlayerName
byte_678640
sgbSentThisCycle
gbActivePlayers
gbGameDestroyed
gbShouldValidatePackage
sgbSendDeltaTbl
sgGameInitInfo
netplr
sglTimeoutStart
sgbNetInited
sgdwPlayerLeftReasonTbl
sgLoPriBuf
sgdwGameLoops
gbMaxPlayers
sgbTimeout
player_state
gbDeltaSender
szPlayerDescript
gdwMsgLenTbl
turn_upper_bit
gdwDeltaBytesSec
gdwTurnsInTransit
glpMsgTbl
nthread_should_run
sgbNetUpdateRate
sgbSyncCountdown
sgbTicsOutOfSync
last_tick
sgbPacketCountdown
sgbThreadIsRunning
gdwLargestMsgSize
gdwNormalMsgSize
glpNThreadId
nobjects
trapid
trapdir
pObjCels
ObjFileList
objectactive
leverid
objectavail
numobjfiles
object
InitObjFlag
gdwPalEntries
logical_palette
orig_palette
system_palette
path_unusednodes
path_2_nodes
pnode_ptr
gdwCurNodes
path_nodes
gdwCurPathStep
pnode_vals
pnode_tblptr
gbValidSaveFile
myplr
plr_bframe_size
plr_sframe_size
plr
plr_hframe_size
plr_wframe_size
plr_fframe_size
deathflag
plr_aframe_size
plr_qframe_size
plr_dframe_size
plr_lframe_size
deathdelay
plr_gfx_flag
plr_gfx_bflag
plr_msgs
portal
portalindex
qtopline
questlog
pQLogCel
quests
qline
WaterDone
qlist
ALLQUESTS
numqlines
ReturnLvlY
ReturnLvlX
ReturnLvlT
ReturnLvl
level_piece_id
arch_draw_type
gpBufEnd
DDS_desc
sgdwCursWdtOld
sgdwCursX
sgdwCursY
cel_transparency_active
sgdwCursHgt
sgdwCursXOld
sgdwCursYOld
draw_monster_num
light_table_index
sgdwCursWdt
level_cel_block
sgdwCursHgtOld
DrawPlrProc
sgSaveBack
PitchTbl
sgSHA1
DSBs
sglpDSB
gbSndInited
sgpMusicTrack
hDsound_dll
sglpDS
sglSoundVolume
sglMusicVolume
stextup
storenumh
stextlhold
boyitem
stextshold
pCelBuff
premiumitem
pSTextBoxCels
premiumlevel
talker
stext
stextsize
stextsmax
storehold
gossipstart
witchitem
stextscrl
numpremium
healitem
golditem
storehidx
pSTextSlidCels
InStoreFlag
stextvhold
stextsel
stextscrldbtn
gossipend
stextsval
boylevel
smithitem
stextdown
stextscrlubtn
stextflag
sgnSyncItem
sync_word_6AA708
sgnSyncPInv
sgnMonsters
sgwLRU
numthemes
armorFlag
ThemeGoodIn
weaponFlag
treasureFlag
mFountainFlag
cauldronFlag
tFountainFlag
zharlib
themes
themex
themey
themeVar1
pFountainFlag
bFountainFlag
bCrossFlag
storeflag
sgnCowMsg
numtowners
sgdwCowClicks
bannerflag
boyloadflag
pCowCels
towner
townwarps
trigflag
numtrigs
trigs
TWarpFrom
WorldBoolFlag
gdwCurrentMask
gpCelFrame
gpDrawMask

@mewmew
Copy link
Contributor

mewmew commented Jul 11, 2019

@AJenbo great you started this issue to track the progress of mapping the global variables to their original addresses. I agree, getting relative offsets correct first seems like the way to go.

Also, we should consider merging @Predelnik fix for the last function, even if it is still not bin perfect, it has the same size with minimal differences which is great for getting the offsets right.

Regarding:

There is the documentation at https://github.com/sanctuary/notes but our naming is different so it would need some work

This is tracked by https://github.com/sanctuary/notes/issues/253

Updating the names of sanctuary/notes to use the original names of Diablo (and those used in Devilution) is not there yet, far from it. But it is definitely the direction to go.

@AJenbo
Copy link
Member Author

AJenbo commented Jul 11, 2019

Other issues I see in the code region is the missing delete operator in appfat. Galaxy mentioned that it probably comes from Storm. It's the very first function in the .text section.

The other issue is the size of pkware and probably also its position.

And then off cause that read only globals should be marked as const.

@mewmew
Copy link
Contributor

mewmew commented Jul 11, 2019

Other issues I see in the code region is the missing delete operator in appfat. Galaxy mentioned that it probably comes from Storm. It's the very first function in the .text section.

We did have the delete operator in there at some point. I think it was one of my first PRs to the project. #110

The other issue is the size of pkware and probably also its position.

Isn't pkware open source? Perhaps not. If it is, then with some luck we should get it to be bin exact quite easily.

And then off cause that read only globals should be marked as const.

This should be an easy one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants