11const std = @import ("std" );
2- const stdout = std .io .getStdOut ().writer ();
32
43const Ram64k = @import ("mem.zig" );
54const Sid = @import ("sid.zig" );
@@ -106,11 +105,11 @@ fn doHardReset(cpu: *Cpu) void {
106105pub fn reset (cpu : * Cpu , hard : bool ) void {
107106 if (hard ) {
108107 if (cpu .dbg_enabled )
109- stdout . print ("[cpu] hard reset\n " , .{}) catch {} ;
108+ std . debug . print ("[cpu] hard reset\n " , .{});
110109 cpu .doHardReset ();
111110 } else {
112111 if (cpu .dbg_enabled )
113- stdout . print ("[cpu] reset\n " , .{}) catch {} ;
112+ std . debug . print ("[cpu] reset\n " , .{});
114113 cpu .reset ();
115114 }
116115}
@@ -163,7 +162,7 @@ pub fn printStatus(cpu: *Cpu) void {
163162
164163 const insn_size = Asm .getInstructionSize (insn );
165164
166- stdout .print ("[cpu] PC: {X:0>4} | {s} | {s} | A: {X:0>2} | X: {X:0>2} | Y: {X:0>2} | SP: {X:0>2} | Cycl: {d:0>2} | Cycl-TT: {d} | " , .{
165+ std . debug .print ("[cpu] PC: {X:0>4} | {s} | {s} | A: {X:0>2} | X: {X:0>2} | Y: {X:0>2} | SP: {X:0>2} | Cycl: {d:0>2} | Cycl-TT: {d} | " , .{
167166 cpu .pc ,
168167 bytesToHex (& cpu .mem .data , cpu .pc , insn_size ),
169168 padTo16 (disasm , 12 , & buf_disasm_pad ),
@@ -173,13 +172,13 @@ pub fn printStatus(cpu: *Cpu) void {
173172 cpu .sp ,
174173 cpu .cycles_last_step ,
175174 cpu .cycles_executed ,
176- }) catch {} ;
175+ });
177176 printFlags (cpu );
178- stdout . print ("\n " , .{}) catch {} ;
177+ std . debug . print ("\n " , .{});
179178}
180179
181180pub fn printTrace (cpu : * Cpu ) void {
182- stdout .print ("PC: {X:0>4} OP: {X:0>2} {X:0>2} {X:0>2} A:{X:0>2} X:{X:0>2} Y:{X:0>2} FL:{X:0>2}" , .{
181+ std . debug .print ("PC: {X:0>4} OP: {X:0>2} {X:0>2} {X:0>2} A:{X:0>2} X:{X:0>2} Y:{X:0>2} FL:{X:0>2}" , .{
183182 cpu .pc ,
184183 cpu .mem .data [cpu .pc ],
185184 cpu .mem .data [cpu .pc + 1 ],
@@ -188,13 +187,13 @@ pub fn printTrace(cpu: *Cpu) void {
188187 cpu .x ,
189188 cpu .y ,
190189 cpu .status ,
191- }) catch {} ;
192- stdout . print ("\n " , .{}) catch {} ;
190+ });
191+ std . debug . print ("\n " , .{});
193192}
194193
195194pub fn printFlags (cpu : * Cpu ) void {
196195 cpu .flagsToPS ();
197- stdout . print ("FL: {b:0>8}" , .{cpu .status }) catch {} ;
196+ std . debug . print ("FL: {b:0>8}" , .{cpu .status });
198197}
199198
200199pub fn readByte (cpu : * Cpu , addr : u16 ) u8 {
@@ -877,17 +876,17 @@ pub fn runStep(cpu: *Cpu) u8 {
877876 cpu .pc = jsr_addr ;
878877 cpu .cycles_executed +%= 1 ; // Matches 6 cycles with fetch and push
879878 if (cpu .dbg_enabled ) {
880- stdout .print ("[cpu] JSR {X:0>4}, return to {X:0>4}\n " , .{
879+ std . debug .print ("[cpu] JSR {X:0>4}, return to {X:0>4}\n " , .{
881880 jsr_addr ,
882881 ret_addr ,
883- }) catch {} ;
882+ });
884883 }
885884 },
886885
887886 Asm .rts .opcode = > {
888887 if (cpu .sp == 0xFF ) {
889888 if (cpu .dbg_enabled ) {
890- stdout . print ("[cpu] RTS EXIT!\n " , .{}) catch {} ;
889+ std . debug . print ("[cpu] RTS EXIT!\n " , .{});
891890 }
892891 cpu .cycles_last_step =
893892 @as (u8 , @truncate (cpu .cycles_executed -% cycles_now ));
@@ -898,17 +897,17 @@ pub fn runStep(cpu: *Cpu) u8 {
898897 cpu .pc = ret_addr + 1 ;
899898 cpu .cycles_executed +%= 2 ;
900899 if (cpu .dbg_enabled ) {
901- stdout .print ("[cpu] RTS to {X:0>4}\n " , .{
900+ std . debug .print ("[cpu] RTS to {X:0>4}\n " , .{
902901 ret_addr + 1 ,
903- }) catch {} ;
902+ });
904903 }
905904 },
906905
907906 Asm .jmp_abs .opcode = > {
908907 const addr : u16 = addrAbs (cpu );
909908 cpu .pc = addr ;
910909 if (cpu .dbg_enabled ) {
911- stdout . print ("[cpu] JMP {X:0>4}\n " , .{addr }) catch {} ;
910+ std . debug . print ("[cpu] JMP {X:0>4}\n " , .{addr });
912911 }
913912 },
914913
@@ -1394,7 +1393,7 @@ pub fn runStep(cpu: *Cpu) u8 {
13941393 if ((cpu .mem .data [0x01 ] & 0x07 ) != 0x5 and
13951394 ((cpu .pc == 0xea31 ) or (cpu .pc == 0xea81 )))
13961395 {
1397- stdout . print ("[cpu] RTI\n " , .{}) catch {} ;
1396+ std . debug . print ("[cpu] RTI\n " , .{});
13981397
13991398 return 0 ;
14001399 }
0 commit comments