mirror of
https://github.com/specht/champ.git
synced 2025-02-19 21:30:42 +00:00
yay
This commit is contained in:
parent
a795946457
commit
50f4dad58c
38
champ.c
38
champ.c
@ -171,6 +171,7 @@ uint16_t read16(uint16_t address)
|
|||||||
|
|
||||||
void refresh_watches(uint16_t address)
|
void refresh_watches(uint16_t address)
|
||||||
{
|
{
|
||||||
|
// refresh global variable watches after write at address
|
||||||
for (int i = 0; i < WATCH_COUNT; i++)
|
for (int i = 0; i < WATCH_COUNT; i++)
|
||||||
{
|
{
|
||||||
if ((WATCH_ADDRESSES[i] == address) ||
|
if ((WATCH_ADDRESSES[i] == address) ||
|
||||||
@ -193,7 +194,7 @@ void refresh_watches(uint16_t address)
|
|||||||
value = (int16_t)read16(WATCH_ADDRESSES[i]);
|
value = (int16_t)read16(WATCH_ADDRESSES[i]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fprintf(watches_file, "0x%04x %s %d\n", cpu.ip, WATCH_LABELS[i], value);
|
fprintf(watches_file, "~ 0x%04x %s %d\n", cpu.ip, WATCH_LABELS[i], value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1144,8 +1145,39 @@ int main(int argc, char** argv)
|
|||||||
uint32_t next_display_refresh = 0;
|
uint32_t next_display_refresh = 0;
|
||||||
uint8_t old_screen_number = 0;
|
uint8_t old_screen_number = 0;
|
||||||
while (1) {
|
while (1) {
|
||||||
// if (cpu.ip >= 0xf5b2)
|
if (watches_file)
|
||||||
// printf("*** ");
|
{
|
||||||
|
// handle register watches for certain IP locations
|
||||||
|
uint8_t printed_reg_watches = 0;
|
||||||
|
for (int i = 0; i < ARG_WATCH_COUNT; i++)
|
||||||
|
{
|
||||||
|
if (cpu.ip == ARG_WATCH_ADDRESSES[i])
|
||||||
|
{
|
||||||
|
int32_t value = 0;
|
||||||
|
uint8_t reg = 0;
|
||||||
|
if (ARG_WATCH_REGISTERS[i] == WATCH_A)
|
||||||
|
reg = cpu.a;
|
||||||
|
else if (ARG_WATCH_REGISTERS[i] == WATCH_X)
|
||||||
|
reg = cpu.x;
|
||||||
|
else if (ARG_WATCH_REGISTERS[i] == WATCH_Y)
|
||||||
|
reg = cpu.y;
|
||||||
|
if (ARG_WATCH_TYPES[i] == WATCH_S8)
|
||||||
|
value = (int8_t)reg;
|
||||||
|
else
|
||||||
|
value = (uint8_t)reg;
|
||||||
|
if (!printed_reg_watches)
|
||||||
|
fprintf(watches_file, "@ 0x%04x ", cpu.ip);
|
||||||
|
else
|
||||||
|
fprintf(watches_file, ", ");
|
||||||
|
fprintf(watches_file, "%s %d",
|
||||||
|
WATCH_REGISTER_LABELS[ARG_WATCH_REGISTERS[i]],
|
||||||
|
value);
|
||||||
|
printed_reg_watches = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (printed_reg_watches)
|
||||||
|
fprintf(watches_file, "\n");
|
||||||
|
}
|
||||||
handle_next_opcode();
|
handle_next_opcode();
|
||||||
if ((start_frame_pc != 0xffff) && (cpu.ip == start_frame_pc))
|
if ((start_frame_pc != 0xffff) && (cpu.ip == start_frame_pc))
|
||||||
{
|
{
|
||||||
|
29
parse.rb
29
parse.rb
@ -1,8 +1,11 @@
|
|||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
|
require 'yaml'
|
||||||
|
|
||||||
label_for_address = {}
|
label_for_address = {}
|
||||||
symbols = []
|
symbols = []
|
||||||
watches = []
|
watches = []
|
||||||
|
arg_watches = []
|
||||||
|
|
||||||
File::open('plot3d20_Output.txt') do |f|
|
File::open('plot3d20_Output.txt') do |f|
|
||||||
f.each_line do |line|
|
f.each_line do |line|
|
||||||
@ -18,6 +21,7 @@ File::open('plot3d20_Output.txt') do |f|
|
|||||||
address = $1
|
address = $1
|
||||||
end
|
end
|
||||||
watch_this = symbol.match(/~(u8|s8|u16|s16)/)
|
watch_this = symbol.match(/~(u8|s8|u16|s16)/)
|
||||||
|
watch_args = symbol.scan(/(@(u8|s8|u16|s16)[AXY])/).map { |x| x.first }
|
||||||
symbol = symbol.strip.split(' ').first
|
symbol = symbol.strip.split(' ').first
|
||||||
next if address.nil?
|
next if address.nil?
|
||||||
label_for_address[address.to_i(16)] = symbol
|
label_for_address[address.to_i(16)] = symbol
|
||||||
@ -29,6 +33,11 @@ File::open('plot3d20_Output.txt') do |f|
|
|||||||
:type => watch_this[1]
|
:type => watch_this[1]
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
watch_args.each do |watch_arg|
|
||||||
|
arg_watches << {:register => watch_arg[watch_arg.size - 1],
|
||||||
|
:type => watch_arg.sub('@', '')[0, watch_arg.size - 2],
|
||||||
|
:address => address.to_i(16)}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -86,6 +95,26 @@ File::open('watches.h', 'w') do |f|
|
|||||||
f.puts "const uint8_t WATCH_TYPES[] = {";
|
f.puts "const uint8_t WATCH_TYPES[] = {";
|
||||||
f.puts watches.map { |x| " #{types.index(x[:type]) + 1}" }.join(",\n");
|
f.puts watches.map { |x| " #{types.index(x[:type]) + 1}" }.join(",\n");
|
||||||
f.puts "};"
|
f.puts "};"
|
||||||
|
|
||||||
|
f.puts "const uint16_t ARG_WATCH_COUNT = #{arg_watches.size};"
|
||||||
|
types = ['u8', 'u16', 's8', 's16'];
|
||||||
|
f.puts "const uint16_t ARG_WATCH_ADDRESSES[] = {";
|
||||||
|
f.puts arg_watches.map { |x| " #{sprintf('0x%04x', x[:address])}" }.join(",\n");
|
||||||
|
f.puts "};"
|
||||||
|
f.puts "const uint8_t ARG_WATCH_TYPES[] = {";
|
||||||
|
f.puts arg_watches.map { |x| " #{types.index(x[:type]) + 1}" }.join(",\n");
|
||||||
|
f.puts "};"
|
||||||
|
registers = ['A', 'X', 'Y']
|
||||||
|
registers.each.with_index do |x, _|
|
||||||
|
f.puts "#define WATCH_#{x} #{_ + 1}"
|
||||||
|
end
|
||||||
|
f.puts "const uint8_t ARG_WATCH_REGISTERS[] = {";
|
||||||
|
f.puts arg_watches.map { |x| " #{registers.index(x[:register]) + 1}" }.join(",\n");
|
||||||
|
f.puts "};"
|
||||||
|
f.puts "const char* WATCH_REGISTER_LABELS[] = {";
|
||||||
|
f.puts " \"\","
|
||||||
|
f.puts registers.map { |x| " \"#{x}\"" }.join(",\n");
|
||||||
|
f.puts "};"
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "Found #{symbols.size} labels and #{watches.size} watches."
|
puts "Found #{symbols.size} labels and #{watches.size} watches."
|
||||||
|
@ -4,11 +4,20 @@ vars = {}
|
|||||||
|
|
||||||
File::open(ARGV.first) do |f|
|
File::open(ARGV.first) do |f|
|
||||||
f.each_line do |line|
|
f.each_line do |line|
|
||||||
parts = line.split(' ')
|
if line[0] == '~'
|
||||||
name = parts[1]
|
parts = line.split(' ')
|
||||||
value = parts[2].to_i
|
name = parts[2]
|
||||||
vars[name] ||= []
|
value = parts[3].to_i
|
||||||
vars[name] << value
|
vars[name] ||= []
|
||||||
|
vars[name] << value
|
||||||
|
elsif line[0] == '@'
|
||||||
|
address = line.split(' ')[1].sub('0x', '').to_i(16)
|
||||||
|
rest = line[line.index(' ', 2), line.size].strip
|
||||||
|
rest.split(',').each do |part|
|
||||||
|
part.strip!
|
||||||
|
# puts part
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
22
watches.h
22
watches.h
@ -36,3 +36,25 @@ const uint8_t WATCH_TYPES[] = {
|
|||||||
4,
|
4,
|
||||||
4
|
4
|
||||||
};
|
};
|
||||||
|
const uint16_t ARG_WATCH_COUNT = 2;
|
||||||
|
const uint16_t ARG_WATCH_ADDRESSES[] = {
|
||||||
|
0x7c92,
|
||||||
|
0x7c92
|
||||||
|
};
|
||||||
|
const uint8_t ARG_WATCH_TYPES[] = {
|
||||||
|
3,
|
||||||
|
3
|
||||||
|
};
|
||||||
|
#define WATCH_A 1
|
||||||
|
#define WATCH_X 2
|
||||||
|
#define WATCH_Y 3
|
||||||
|
const uint8_t ARG_WATCH_REGISTERS[] = {
|
||||||
|
3,
|
||||||
|
1
|
||||||
|
};
|
||||||
|
const char* WATCH_REGISTER_LABELS[] = {
|
||||||
|
"",
|
||||||
|
"A",
|
||||||
|
"X",
|
||||||
|
"Y"
|
||||||
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user