Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Ghidra with illegal opcodes
2024-05-13 18:39
Grue

Registered: Dec 2001
Posts: 162
Ghidra with illegal opcodes

Recently, Kakka / Extend added 6510 illegal opcode decoding support for the Ghira fork, which I have been using on my C64 game mods.
Note that you must choose the 6510 variant of MOS6502 to use it as a CPU for your binary.

https://github.com/grue74/ghidra-c64helpers

And binaries for Linux and Windows here also, the c64 byte viewer as a plugin can be found:

https://voidhole.com/~grue/ghidra/

I don't know how to use the debugger with ghidra, so I don't know if those illegals work ok, but at least they seem to work ok on the code lister.

Ghidra is a pretty good replacement for the IDA Pro; at least, you cannot beat the price.

I update those builds semi-randomly with the latest updates from the official ghidra tree.
2024-05-13 20:02
Colt45RPM

Registered: Feb 2019
Posts: 47
Awesome! Thanks so much. I have been wishing for something like this. :)
2024-05-13 20:13
Frantic

Registered: Mar 2003
Posts: 1648
Cool!
2024-05-15 15:15
chatGPZ

Registered: Dec 2001
Posts: 11390
Really need to look at Ghidra some day... So hard to drop IDA once you learned it :)
2024-05-16 06:02
Grue

Registered: Dec 2001
Posts: 162
This fork of ghidra mainly distributes my hacks on the byte viewer plugin, which introduces several different mappings to character encodings.

For the best results, use the c64 pro mono font.

An example of the byte viewer plugin options can be seen here:

https://voidhole.com/~grue/ghidra_example.png

I made the mappings using the new retro computing standards for UTF-8, but the C64 Pro Mono font has not been updated yet to conform to that, so some of the characters cannot be shown.

A font called Unscii should handle those, but I personally don't like how it looks.

ps. I mapped screencode chars to petscii maps when there was no sensible mapping available.
2024-05-16 17:42
chatGPZ

Registered: Dec 2001
Posts: 11390
the "Pet Me" font should support that official mapping
2024-05-17 06:57
Grue

Registered: Dec 2001
Posts: 162
Quote: the "Pet Me" font should support that official mapping

Thanks for the tip. The ghidra builds have now been updated to follow Pet Me font mappings.
Characters 0-127 conform to UTF8 standards, and 128-255 don't, as there don't seem to be inverted characters on Unicode mappings.
2024-05-17 12:47
Fungus

Registered: Sep 2002
Posts: 691
I need to check this out too, I miss using IDA, but no idea how to use it with C64 stuff.
2024-05-17 14:50
chatGPZ

Registered: Dec 2001
Posts: 11390
You need IDA Pro, that has the 6502 module (with illegals even).

I wouldn't use IDA for C64 things if i didn't already know it quite good - all the x86-isms can be confusing and annoying :)

Now if someone would convince Ilfak to update Hexrays for 6502 - that would be a different story :D
2024-05-18 03:59
Fungus

Registered: Sep 2002
Posts: 691
Hexrays for 6502 would be awesome, just a pipedream though.
2024-05-18 10:52
tlr

Registered: Sep 2003
Posts: 1791
I've also thought about using ghidra a while ago, installed it and didn't really get acquainted to it. Maybe I should give it another go.
2024-05-18 21:35
Digger

Registered: Mar 2005
Posts: 438
Has anyone run it successfully on macOS?
2024-05-19 15:05
oziphantom

Registered: Oct 2014
Posts: 490
Ghidra is awesome, but I kind of feel that it is overkill for a C64 game. Regenerator, I think handles it better, once you get into the split hi/lo table -1 etc

Also getting direct 64tass output files while Ghidra's is more designed for "you can read the code and copy paste a function"
2024-05-19 15:55
Fungus

Registered: Sep 2002
Posts: 691
If Ghidra has the flow chart and shows branches and loops connected, it will be very useful even if it doesn't give source files.

If it has that, I'm going to start poking with it immediately as it will make reversing what routines do much easier.
2024-05-19 16:35
Grue

Registered: Dec 2001
Posts: 162
Quote: If Ghidra has the flow chart and shows branches and loops connected, it will be very useful even if it doesn't give source files.

If it has that, I'm going to start poking with it immediately as it will make reversing what routines do much easier.


It has, that's the reason why it's mostly useful.

I prefer the 6502bench for creating the source code as other tools I've tried feel way too limited, and there are also annoying limitations in 6502bench :)

My workflow is more or less:

RetroDebugger for investigating and saving binary to work with.
Ghidra for preliminary work to figure out how everything works and then move to 6502bench to make the relocatable source code.

You can, of course, skip the ghidra and move right on to 6502bench if you eat and shit the 6502 code, but I appreciate the help Ghidra can provide me.

To use my symbol files for the Ghidra, you must create 3 layers In the RAM section.

I really should make a short video about how to get started, as it's quite difficult to get started without any pointers. I'm not even sure if my method is the most sensible one..
2024-05-19 16:57
chatGPZ

Registered: Dec 2001
Posts: 11390
Mmmh you cant produce an asm file right from ghidra? That always was a key feature in IDA for me
2024-05-19 17:32
Grue

Registered: Dec 2001
Posts: 162
Quote: Mmmh you cant produce an asm file right from ghidra? That always was a key feature in IDA for me

You can export something which is not very useful for the assemblers.

Of course, it's open source, so...
2024-05-19 17:58
Grue

Registered: Dec 2001
Posts: 162
A quick video about how to get started. Sorry about messy results, I wasn't preparing beforehand, just started to record and it shows..

https://youtu.be/xNFswb9CVkg
2024-05-20 11:10
oziphantom

Registered: Oct 2014
Posts: 490
this is more SNES and 65816 based, but I have a pile of fancy scripts here https://github.com/oziphantom/SNES_DOCS/tree/main/scripts maybe it has been fixed now but the 6502 plugin got somethings wrong, the 65816 gets everything backwards. So I have some clean up scripts. I also have some add hi/lo tables, add references, instance N structs kind of scripts. For Harvest moon I have example "How to look at and display sprites" that could be cribbed to make a C64 sprite viewer or block map viewer etc

If you go up a couple of levels I have the start of a walk through on how to start on a SNES project, but doing a C64 would be almost the same steps just with a different memory map and less initial state steps.

For getting a 64Tass listing out of it, I was going to make a script that pulled the data from Ghidra and spat out the code files.
2024-06-11 11:31
Grue

Registered: Dec 2001
Posts: 162
I checked against the official Ghidra repo and built new binaries at the usual place.
2024-09-27 19:02
Grue

Registered: Dec 2001
Posts: 162
Ghidra released official 11.2 so I updated my builds and theres now 11.3dev version available. Linux and Windows builds.
2024-09-30 16:36
Bacchus

Registered: Jan 2002
Posts: 156
@Grue,

I moved from Regenerator to 6502Bench as well. I have done a number of videos where it's used.

https://www.youtube.com/watch?v=78327vjQiV0

https://www.youtube.com/watch?v=i_KMQF0SwDg

/Bacchus
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
iAN CooG/HVSC
Airwolf/F4CG
Higgie/Kraze/Slackers
Twoflower/ΤRIΛD
Guests online: 151
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Coma Light 13  (9.6)
4 Edge of Disgrace  (9.6)
5 Mojo  (9.6)
6 Uncensored  (9.6)
7 The Demo Coder  (9.6)
8 Comaland 100%  (9.6)
9 Wonderland XIV  (9.6)
10 What Is The Matrix 2  (9.6)
Top onefile Demos
1 Layers  (9.7)
2 Cubic Dream  (9.6)
3 Party Elk 2  (9.6)
4 Copper Booze  (9.6)
5 Rainbow Connection  (9.5)
6 Morph  (9.5)
7 Dawnfall V1.1  (9.5)
8 Libertongo  (9.5)
9 Katzen-Video.mp4  (9.5)
10 Onscreen 5k  (9.5)
Top Groups
1 Booze Design  (9.3)
2 Oxyron  (9.3)
3 Performers  (9.3)
4 Fairlight  (9.3)
5 Triad  (9.3)
Top Organizers
1 Burglar  (9.9)
2 Sixx  (9.8)
3 MWS  (9.7)
4 hedning  (9.7)
5 Tim  (9.7)

Home - Disclaimer
Copyright © No Name 2001-2025
Page generated in: 0.061 sec.