1 /****************************************************************************/
2 /* */
3 /* Source file for handling Bp in core kernel */
4 /* */
5 /* For the user Bp, we just give the hand to the user */
6 /* For the GIVE_HAND_BP, we make it disappear and we give hand to user */
7 /* For the RESTORE_BP, we set again the User BP placed old_user_bp in the */
8 /* list then we make the current BP to disappear then set IP,... */
9 /* */
10 /* There are certainly a lot of improvement to do, If you got any idea : */
11 /* Zeograd@caramail.com */
12 /* */
13 /****************************************************************************/
14
15 #include "globals.h"
16 #include "debug.h"
17 #include "h6280.h"
18
19 int handle_bp(int nb_bp);
20
handle_bp0()21 int handle_bp0()
22 {
23 return handle_bp(0);
24 }
25
handle_bp1()26 int handle_bp1()
27 {
28 return handle_bp(1);
29 }
30
handle_bp2()31 int handle_bp2()
32 {
33 return handle_bp(2);
34 }
35
handle_bp3()36 int handle_bp3()
37 {
38 return handle_bp(3);
39 }
40
handle_bp4()41 int handle_bp4()
42 {
43 return handle_bp(4);
44 }
45
handle_bp5()46 int handle_bp5()
47 {
48 return handle_bp(5);
49 }
50
handle_bp6()51 int handle_bp6()
52 {
53 return handle_bp(6);
54 }
55
handle_bp7()56 int handle_bp7()
57 {
58 return handle_bp(7);
59 }
60
handle_bp8()61 int handle_bp8()
62 {
63 return handle_bp(8);
64 }
65
handle_bp9()66 int handle_bp9()
67 {
68 return handle_bp(9);
69 }
70
handle_bp10()71 int handle_bp10()
72 {
73 return handle_bp(10);
74 }
75
handle_bp11()76 int handle_bp11()
77 {
78 return handle_bp(11);
79 }
80
handle_bp12()81 int handle_bp12()
82 {
83 return handle_bp(12);
84 }
85
handle_bp13()86 int handle_bp13()
87 {
88 return handle_bp(13);
89 }
90
handle_bp(int nb_bp)91 int handle_bp(int nb_bp)
92 {
93
94 #ifndef FINAL_RELEASE
95 if (reg_pc!=Bp_list[nb_bp].position)
96 fprintf(stderr,"there's a problem, the breakpoint hasn't been correctly hit\n");
97 else
98 fprintf(stderr,"The breakpoint %d has been correctly hit\n",nb_bp);
99
100 fprintf(stderr,"After Breakpoint, position is %X\n",reg_pc);
101 #endif
102
103 disass_menu(reg_pc);
104 // And call the disassembler
105
106 #ifndef FINAL_RELEASE
107 fprintf(stderr,"After the disassembly function, the position is %X\n",reg_pc);
108 #endif
109
110 if ((get_8bit_addr(reg_pc)&0x0F)==0x0B)
111 { // We only look here for Bp since PC or bp status can have changed
112
113 #ifndef FINAL_RELEASE
114 fprintf(stderr,"run trick: a bp has been asked to be put at %X\n",reg_pc);
115 #endif
116
117 Wr6502(reg_pc,Bp_list[get_8bit_addr(reg_pc)>>4].original_op);
118 // Replace the opcode in the rom
119
120 Bp_list[get_8bit_addr(reg_pc)>>4].flag=NOT_USED;
121 // Temporary, the breakpoint disappears
122 // to be replaced by the restore_bp
123
124 Bp_pos_to_restore=reg_pc;
125 // We know we must restore a breakpoint at this point
126
127 set_bp_following(reg_pc,RESTORE_BP);
128 // since we call this after disassembly call, we handle correctly
129 // any changes in reg value e.g.
130
131 }
132
133 return 0;
134
135 }
136
137 int
handle_bp14()138 handle_bp14()
139 {
140 // We must restore the Bp_to_restore Breakpoint
141 Wr6502(reg_pc,Bp_list[14].original_op);
142
143 // Replace the opcode in the rom
144
145 Bp_list[14].flag=NOT_USED;
146 // This BP is no more used
147
148 #ifndef FINAL_RELEASE
149 fprintf(stderr,"We're restoring bp at %X\n",Bp_pos_to_restore);
150 #endif
151
152 toggle_user_breakpoint(Bp_pos_to_restore);
153 // We set another Bp at the location we just left
154
155 return 0;
156 }
157
158 int
handle_bp15()159 handle_bp15(){
160 // We must make it disappear and call the disassembler
161
162 Wr6502(reg_pc,Bp_list[15].original_op);
163 // Replace the opcode in the rom
164
165 Bp_list[15].flag=NOT_USED;
166 // This breakpoint is no more used
167
168 disass_menu(reg_pc);
169
170 return 0;
171 }
172