I want to create a structure for use with a high score table, something of the nature:
struct highscores
hs_score dd 0
hs_name db 4
ends
(producing a constant highscores_struct_len = 8, if possible)
then populate my highscore table using the struct, something like
highscore_table:
highscores 5,abc
highscores 10,def
highscores 15,ghi
producing the following data
highscore_table
dd 5
db "abc",0
dd 10
dd "def",0
dd 15
dd "ghi",0
is this possible? what would be the correct syntax
MAX_HIGH_SCORES equ 10
highscores STRUCT
hs_score DD ?
hs_name DB 4 DUP (?)
highscores ENDS
.DATA
Scores highscores MAX_HIGH_SCORES DUP (<?>)
index dd ?
szname db "abc",0
.CODE
mov eax, [index]
mov [Scores[eax].hs_score], 15
invoke lstrcpyn, [Scores[eax].hs_name], offset szname, 4
[index] would contain a number from 0 to MAX_HIGH_SCORES-1 that would be the position in the array where the high score is placed.
For constant initialization you can also use
highscores struct
hs_score dd ?
hs_name db 3 dup (?)
_zero db 0
highscores ends
highscore_table highscores <5, "abc">
highscores <10, "def">
highscores <15, "ghi">
Thanks guys :U