9 Pendean Burgess Hill West Sussex RH15 ODW Sometime JAN'92 Greetings Mark/Ray/All ACC users! Having 'discovered' ACC as of about issue 18, I have decided to send in some of my code - having learnt machine code on 3 computers now, on minimal cash, and without ever speaking to another coder (GASP!) I know how hard learning to code can be! Before I begin waffling on about my submitted source, a few notes about me, coding, and a few questions... I have been coding on the amiga now for some one and a half years - I am pretty much a lone coder, never really being a member of a serious 'group'. I mostly code `hardware` routines - sprites/text/disk/vector routines etc. I make a point of using include files, either for equates or for actual code - this improves readability & makes the stuff MUCH easier to understand 6 months later! I also am trying to build up a library of source subroutines to simplify further coding. I know Mark has gone on about linking code for a bit now, but until a fast linker comes built-in with either Argasm or Devpac, linking will really slow code development down - except on a hard-disk or large projects. I purchased Devpac 3 from HiSoft at the Commodore Show at the end of '91. It was good to see quite a few 'serious' companies showing their wares - hopefully games won't have completely taken over by the 92 show... Devpac 3 is a major improvement over Devpac 2 in many respects - to start with you get 4 disks (WB 2 & 1.3 versions, 2 disks each) ; though the most obvious improvement is the vastly improved now-multi-windowing editor - its so good I've stopped using Cygnus Ed.. Symbolic debugging,680x0 support, and symbol files (to speed up includes) are just some of the improvements... I recommend an upgrade if you've got Devpac 2. Enough chat! A question that's been bugging me now: In issue 18 Trog had a few routines censored for being the subject of piracy etc. (I agree with this, on the subject of cracking any way.) What I want to know is if (say) making a game installable on a hard disk, for personal use only, is against the copyright laws? For example, turning Stunt Car racer into an executable file... - is this illegal. I totally abhor piracy given the time/money/stress/LIFE gone into creating anything... but is making an 'honest' back-up illegal ? I realise that most people are unable to do this sort of thing, but as a CODER its a cinch, and given that I am not going to 'SPREAD' any copies, I would like to know! (Ray/Mark - tack one of those `NOTE FROM RAY AT..` type notes at the end of this if possible...) THE CODE (at last!) +===================+ There are 3 pieces of code this month: (Should be compatible with all DEVPACs) 1. Screen Typer 3. In an earlier issue, M.Cross put togther a text routine. This is an improvement on that, and it now supports: Any sized fonts/colour fonts/Justification (implemented) The code has been re-written, and based loosely around the code that Dean Ashton used on disk #18 in `diskcoder` for screen output. It is mainly self explanatory. Note the use of macros and 'rs' equates to simplify using the structures - Genam is a MACRO assembler, so it kind-of makes sense to use its abilities! The source is well commented, so shouldn't present any problems. Please read the notes on font usage in the source... Also note that I've only tried the routine out on a few fonts... BUGS? My code? Never!... I am not doing any error checking or clipping of text on screen (yet ?) as I assume people debug their work ok... 2. Debug v0.01. The trouble with code that temporarily disables the OS is that at times it can be SHEAR HELL to debug - custom disk routines for instance are a real pain! (If anyone has a debugger that can step in SUPERVISOR mode, or emulate that, then SEND IT TO ME SVP!!! Thanks! I'll send something back!) This code replaces all of the system exception vectors with its own, and (say) if a bus error occurs, pops up with its own screen giving details of crash address, register contents, status register, etc. There is also a dump of memory - using the mouse this can be made to point at where any of the cpu reguisters are pointing. This is an early version! It needs quite a bit of work... If I get round to it, I will improve on it... A little note on exceptions: For all errors other than BUSERR or Address errors, the 68000 just puts the status register and return PC value on the stack, in supervisor mode. (As if a TRAP #0 instruction was issued or whatever..) If a BUSERR or Address error occurs more data is put on the stack: N.B. On other 680x0 processors this is different! Bits: 15 5 4 3 2 1 0 A7 ///////// R/W I/N Access +2 High word of error address +4 Low word of error address +6 First word of instruction +8 SR +10 PC high word +12 PC low word If: R/W is 1 it means that the crash occurred during a memory READ,WRITE if 0 I/N is 0 it means that the processing was doing an instruction 1 if detected by an external device. (NEVER had this happen to me!) ACCESS The only values assigned on the 68000 are: 1 User mode data reference 2 User mode program reference 5 SUPERVISOR data reference 6 SUPERVISOR program reference 7 Interrupt acknowledge. My program doesn`t make much of an attempt to restart the code, and is based mostly on the code example in 'Programming the 68000' by Steve Williams (SYBEX) - look here for more info on exception processing if you need it. 3. 3d stars. This is for all those demo freaks out there... This program puts up a spining 3d starfield up on an overscanned 2 bitplane screen. The code can handle up to 200+ stars, with nothing else going on.... The key point about starfields is that as all of the stars are being translated by the same amount each frame, it is not necessary to rotate all of the stars individually... What is done is to rotate a single VECTOR by some varying angles, and then use this vector to translate all the stars by this amount. (ie. simply add its x,y,z components.). All that then remains is to apply perspective to the coordinates, and to plot the stars on screen,after clipping. The source is fairly well commented, and also has a few suggestions for different effects - for example varying the vector that is used for rotation/translation or blitting bobs instead of dots. Note that if you do this, and the star field is dense enough you need to plot the bobs from back to front (depth sort/painters algorithm) to maintain the 3d picture. ( Or you can just forget about that and hope people don't look too closely!) N.B. The routine is run on a vertical blank interrupt. If you slow the code for any reason (bobs etc.) turn down the number of stars so that the routine can work still in the blanking gap - else you'll get a crash as interrupts keep on queueing up & the supervisor stack hits something important! If anyone wants to write to me they can, and I'm willing to chat/help etc. I am open to suggestions as to what to code/send - I could do a 3d filled vectors or clipping tutorial or something - but I don't want to have to explain maths that is READILY AVAILABLE IN GCSE/A LEVEL TEXTBOOKS!. I congratulate DAVE EDWARDS on his excellent blitter & animation code... DAVE: If you've upgraded blitter3.s to use a blitter interrupt server to hit the blitter or have revised it quite a bit, then I wouldnt mind a copy since it will save me a tonne of coding sometime in the future! Thanks! Signing off: Paul Kent 12.1.92 ...getting closer... PS. You are welcome to write to me (address at top of letter), but please bear in mind that as a full time student (A levels) sometimes several tonnes of work gets dropped on me!