6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Sep 22, 2024 9:34 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sun Aug 09, 2020 6:15 pm 
Offline

Joined: Fri Nov 16, 2018 8:55 pm
Posts: 71
I've returned to my Save New York cartridge disassembly project. The source code now builds, but I'm a very long way from done. Even though I've only commented about 5% of the source code at this point, I've built up a lot of other useful data into a spreadsheet like subroutine memory locations, kernal API calls, etc.

At this point, I think I'm nearing the end of the game's bootstrap and initialization routines. Even this early in the game, I see some variables in system memory that have caught my eye. There is one memory location in particular that I suspect may toggle the state machine of the entire game between "demo" "player 1" and "player 2" or something like that. But, I can't really prove it yet.

I'd like to be able to use VICE's machine language monitor to poke in one of the other potential values into that memory location and resume execution of the code. I don't see an obvious option for that. Can someone here point me in the right direction? In this case I just want to be able to change a single byte value.

There is also a broader case where I see a bunch of stuff gets copied out of the CHARGEN ROM area and then modified with bitwise operations. I think this is where the existing character set is getting modified to produce tile based graphics. Presumably, this is more space efficient on an 8k cartridge than a bunch of immediate mode writes with the same data. If that seems nonsensical, let me know and I'll paste the routine here for others to comment on.

How do I dump a larger segment of memory to file? I see dump and undump, but I must be doing it wrong as it's just giving me errors. Once I have that I can prove out my theory any number of ways.


Top
 Profile  
Reply with quote  
PostPosted: Mon Aug 10, 2020 2:14 pm 
Offline

Joined: Fri Nov 16, 2018 8:55 pm
Posts: 71
After quite a bit of digging, I found a working solution for making single byte edits to memory using the VICE monitor.

Spiro's CBM Blog had a detailed tutorial series on how to use the VICE monitor. The VICE monitor - part V: Debugging program execution (via Wayback Machine) has a reader question and reply that covers this:

Q: Is it possible to cursor over memory addresses and change them after listing with the m command? most monitors do but vice doesn't?

A: Hello, first of all, I am sorry for not blogging for so long. I did not have much time lately. Indeed, you can change memory address. For this, you must use the ">" command. Have a look here:

Code:
** Monitor 000 000
(C:$e5d1) m 002b 002c
>C:002b  01 08                      ..
(C:$002d) >C:002b 12
(C:$002d) m 002b 002c
>C:002b  12 08                      ..


I'll still have to play around with the memory dumper. I figured out that the VICE monitor can also log CPU history, which will be great for my project. Unfortunately, it's disabled at compile time by default. So, I'll have to rebuild VICE. No big deal.


Top
 Profile  
Reply with quote  
PostPosted: Wed Aug 12, 2020 11:30 pm 
Offline

Joined: Tue Jul 24, 2012 2:27 am
Posts: 674
The monitor has a built-in help command, via "?". For saving & loading you want save/load/bsave/bload. The 'b' prefixed versions make a plain binary file from an address range, while save/load prefix it with a 2-byte load address a la c64 .prg files.

Code:
(C:$e5cf) ? bsave

Syntax: bsave "<filename>" <device> <address1> <address2>
Abbreviation: bs

Save the memory from address1 to address2 to the specified file.
If device is 0, the file is written to the file system.

(C:$e5cf) ? bload

Syntax: bload "<filename>" <device> <address>
Abbreviation: bl

Load the specified file into memory at the specified address.
If device is 0, the file is read from the file system.

_________________
WFDis Interactive 6502 Disassembler
AcheronVM: A Reconfigurable 16-bit Virtual CPU for the 6502 Microprocessor


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: