From: Mike McCarty (jmccarty_at_ssd.usa.alcatel.com)
Date: 2001-03-05 18:24:47
On Sun, 4 Mar 2001, Ullrich von Bassewitz wrote: > > On Sat, Mar 03, 2001 at 04:37:53PM -0500, Raj Wurttemberg wrote: > > I'm familiar with standard ANSI C & C++ programming and would like to write > > some programs for the C64 and C128 but I see that a lot of the "cool" > > functions require PEEKs and POKEs. For example on a C64: > > > > POKE 199,1 > > > > will change the output to reverse video. How would you do this with cc65? > > I had to answer this question three times in the last few days, so I've > started to write the FAQ:-) > > See > > http://www.cc65.org/faq.php > > for an answer to your question. It's wonderful that you've gotten started like that. I take exception to your statement For better readability you may want to use macros: #define POKE(addr,val) (*(unsigned char *)(addr)=(val)) This definitely REDUCES readability and obscures what the code is doing. Which code is easier for you to read? (a) VideoMode = VIDEO_REVERSE; (b) POKE(199,1) /* Set video mode to reverse */ I agree that macros may enhance readability in this area, but not these particular macros. The suggested answer I give is: #include "video.h" ... VideoMode = VIDEO_REVERSE; ... and in video.h we have #define VIDEO_REVERSE 1 #define VideoMode (*(unsigned char *)199) C has the capability to make code readable and understandable. Providing macros with names like PEEK and POKE is an undesireable step into the past. I recommend that people NOT implement PEEK and POKE at all. The direct C is more readable than the macros. Even better is to implement macros which make the code understandable without having to add comments. Mike ---- char *p="char *p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);} This message made from 100% recycled bits. I can explain it for you, but I can't understand it for you. I don't speak for Alcatel <- They make me say that. ---------------------------------------------------------------------- To unsubscribe from the list send mail to majordomo_at_musoftware.de with the string "unsubscribe cc65" in the body(!) of the mail.
This archive was generated by hypermail 2.1.3 : 2001-12-14 22:05:39 CET