Here is what my file looks like
3535353535353535353535358835353535353535
3535353535353535000000000035353535008035
3535353535353535003535353535353535003535
3535000000000000003500353535353535003535
3535003535353535353500353535353535003535
3535003535350035353500000000000035003535
3535000000000035353500353535350000003535
3535353535350000000000358000353535000035
3535353535353535353535353500353535350035
3580000000000000003535353500353535000035
3535353535003535000000000000353535003535
3535350000003535003535353500353535000035
3535350035353535003535353500353535350035
3500000035353535000035353500000000350035
3500353500000035353535353535353500350035
3500353500350000353535353580353500350035
3500003500353500353535353500353500000035
3535000000353500000000000000353535003535
3535353580353535353542353535353535803535
3535353535353535353535353535353535353535
I would need to be able to get two number from the file. Right now I am only get 1 number instead of the intend two that I am trying to get to from the file.
For example starting at the top of the file 35,35,35
Instead I am getting only 3,5,3,5
.data
Maze DWORD 00,00,00,00,00,35,35,35,35,35,35,35,88,35,35,35,35,35,35,35
rowSize = ($ - Maze)
DWORD 35,35,35,35,35,35,35,35,00,00,00,00,00,35,35,35,35,00,80,35
DWORD 35,35,35,35,35,35,35,35,00,35,35,35,35,35,35,35,35,00,35,35
DWORD 35,35,00,00,00,00,00,00,00,35,00,35,35,35,35,35,35,00,35,35
DWORD 35,35,00,35,35,35,35,35,35,35,00,35,35,35,35,35,35,00,35,35
DWORD 35,35,00,35,35,35,00,35,35,35,00,00,00,00,00,00,35,00,35,35
DWORD 35,35,00,00,00,00,00,35,35,35,00,35,35,35,35,00,00,00,35,35
DWORD 35,35,35,35,35,35,00,00,00,00,00,35,80,00,35,35,35,00,00,35
DWORD 35,35,35,35,35,35,35,35,35,35,35,35,35,00,35,35,35,35,00,35
DWORD 35,80,00,00,00,00,00,00,00,35,35,35,35,00,35,35,35,00,00,35
DWORD 35,35,35,35,35,00,35,35,00,00,00,00,00,00,35,35,35,00,35,35
DWORD 35,35,35,00,00,00,35,35,00,35,35,35,35,00,35,35,35,00,00,35
DWORD 35,35,35,00,35,35,35,35,00,35,35,35,35,00,35,35,35,35,00,35
DWORD 35,00,00,00,35,35,35,35,00,00,35,35,35,00,00,00,00,35,00,35
DWORD 35,00,35,35,00,00,00,35,35,35,35,35,35,35,35,35,00,35,00,35
DWORD 35,00,35,35,00,35,00,00,35,35,35,35,35,80,35,35,00,35,00,35
DWORD 35,00,00,35,00,35,35,00,35,35,35,35,35,00,35,35,00,00,00,35
DWORD 35,35,00,00,00,35,35,00,00,00,00,00,00,00,35,35,35,00,35,35
DWORD 35,35,35,35,80,35,35,35,35,35,42,35,35,35,35,35,35,80,35,35
DWORD 35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35
LEFTRIGHT DWORD 4
BUFFER_SIZE = 5000
buffer BYTE BUFFER_SIZE DUP(?)
bytesRead DWORD ?
Map BYTE "inputfile.txt",0
.code
main PROC
mov edx, 0 ;Register to end game
INVOKE GetTickCount
mov startTime, eax
GameLoop:
cmp edx, 99 ;End game value equals 99
je EndGame
call OpenMap
call TimerScore
call ReadKey
jz GameLoop
cmp ah, 72 ;Up arrow key
je Up
cmp ah, 80 ;Down arrow key
je Down
cmp ah, 75 ;Left arrow key
je Left
cmp ah, 77 ;Right arrow key
je Right
Up:
call UpMove
call Next
Down:
call DownMove
call Next
Left:
call LeftMove
call Next
Right:
call RightMove
call Next
Next:
jmp GameLoop
EndGame:
call TimerCount
call Crlf
call WaitMsg
exit
main ENDP
OpenMap PROC
mov edx, OFFSET Map ;Open the file
call OpenInputFile
push eax ;Push the register on the stack
mov edx, OFFSET buffer ;points to the buffer
mov ecx, BUFFER_SIZE ;max bytes to read
call ReadFromFile ;read the file
mov bytesRead, eax ;count of bytes read
pop eax ;Pop the register off the stack
call CloseFile ;Close the file
mov esi, offset buffer ;Point to the buffer
mov ecx, bytesRead ;Loop counter
LoadFile:
mov al, byte ptr [edi] ;get byte at current pointer
mov byte ptr [edi], al ;move that decrypted byte back to our buffer at current pointer
inc edi ;point to the next byte
mov esi, OFFSET Maze
mov [esi], al ;move the character into the 2D array
add esi, LEFTRIGHT
loop Loadfile ;loop ;loop
mov edx, OFFSET buffer ;Display the buffer
ret
OpenMap ENDP
I decided it would be easyer to read the character rather then the number for the character....
sound now my code looks like this...
OpenMap PROC
mov edx, OFFSET Map ;Open the file
call OpenInputFile
push eax ;Push the register on the stack
mov edx, OFFSET buffer ;points to the buffer
mov ecx, BUFFER_SIZE ;max bytes to read
call ReadFromFile ;read the file
mov bytesRead, eax ;count of bytes read
pop eax ;Pop the register off the stack
call CloseFile ;Close the file
mov edi, offset buffer ;Point to the buffer
mov ecx, bytesRead ;Loop counter
LoadFile:
mov al, byte ptr [edi] ;get byte at current pointer
mov byte ptr [edi], al ;move that decrypted byte back to our buffer at current pointer
inc edi ;point to the next byte
mov esi, OFFSET Maze
mov ebx, [esi]
movzx ebx, al ;Move the charater into eax
mov [esi], ebx
add ebx, 4
loop Loadfile ;loop
mov edx, OFFSET buffer ;Display the buffer
;call WriteString
ret
OpenMap ENDP
and my file looks like this....
I am just testing for the top values but still have no results of printing the area this way in my draw function.
############X########
#####################
#####################
#####################
#####################
#####################
#####################
#####################
#####################
#####################
#####################
#####################
#####################
#####################
#####################
#####################
#####################
#####################
#########*###########
#####################
;=========================================================================
;=========================================================================
Draw PROC
mov dh, 0 ;Set maze position X
mov dl, 0 ;Set maze position Y
call Gotoxy ;Call Go to X Y
mov ebx, OFFSET Maze ;Move the maze 2D array into ebx
mov ecx, 0 ;intialize the counter
PrintLoop:
mov eax, [ebx] ;Move the indirect value of ebx postion 1 into eax
add ebx, 4 ;Move to the next offset position
inc ecx ;Increment the counter
call WriteChar ;Write Character
cmp ecx, 20 ;Compare for end of row for each 20 positions
je NextLine
cmp ecx, 40
je NextLine
cmp ecx, 60
je NextLine
cmp ecx, 80
je NextLine
cmp ecx, 100
je NextLine
cmp ecx, 120
je NextLine
cmp ecx, 140
je NextLine
cmp ecx, 160
je NextLine
cmp ecx, 180
je NextLine
cmp ecx, 200
je NextLine
cmp ecx, 220
je NextLine
cmp ecx, 240
je NextLine
cmp ecx, 260
je NextLine
cmp ecx, 280
je NextLine
cmp ecx, 300
je NextLine
cmp ecx, 320
je NextLine
cmp ecx, 340
je NextLine
cmp ecx, 360
je NextLine
cmp ecx, 380
je NextLine
cmp ecx, 400
jne PrintLoop
jmp Print
NextLine:
call Crlf
jmp PrintLoop
Print:
call Crlf
mov edx,OFFSET MessageDirections
call WriteString ;Call Write String procdure
ret
Draw ENDP
This post has been edited by Toadill: 09 December 2012 - 10:52 AM

New Topic/Question
Reply



MultiQuote








|