=========================================================================== ÓORRY THAT THIS IS LATER THAN É HAD HOPED TO GET IT OUT, BUT HERE IT IS -- ÅXPECT ANOTHER ONE SOON IN A MONTH OR TWO DEPENDING ON SUBMISSIONS... ÐRAISE, ÃOMMENTS, (ÉT SUCKS, É LOVED IT, ETC) ARE WELCOME -> DUCK@PEMBVAX1.PEMBROKE.EDU. ÍANY THANKS TO ÃRAIG ÂRUCE FOR HIS ARTICLE ON LINE DRAWING / DOT PLOTTING WITH THE 80 COLUMN SCREEN ON THE Ã=128. =============================================================================== ÈACKING / ÔHIS ÍAGAZINE BY ÃRAIG ÔAYLOR DUCK@PEMBVAX1.PEMBROKE.EDU ÄEF: ÈACKER - ÎOUN - Á TALENTED AMATEUR USER OF COMPUTERS. ÓOURCE - ×EBSTER'S ÎEW ×ORLD ÄICTIONARY ÃORRECTION: ÈACKER - ÎOUN - Á TALENTED USER OF COMPUTERS. ÔHERE, NOW THAT WE GOT THAT OUT OF THE WAY, LET'S SEE HOW SOME PEOPLE INTERPRET THE WORD HACKER. ÉN THE 1980'S NEWSPAPERS, MAGAZINES, MOVIES - EVERYWHERE YA LOOKED PEOPLE WERE USING THE TERM "ÈACKER" TO DENOTE A PERSON WHO MALICIOUSLY TRIED TO DESTROY / BORE ILL INTENT TOWARDS ANOTHER COMPUTER SYSTEM. ÔHIS WAS THE RESULT OF THE MISUNDERSTANDING OF THE ACTUAL DEFINITION OF "ÈACKER" (UNDER MY CORRECTION ABOVE). ÔHIS MAGAZINE WILL NOT TELL PEOPLE HOW TO "PHREAK", HOW TO HHACK VOICE MAILBOXES AND OTHER ILLEGAL ACTIVITIES. ÈOWEVER, IT WILL ATTEMPT TO REVEAL SOME OF THE "MYSTIQUE" BEHIND SOME OF THE NEW TECHNIQUES AND ABILITIES FOUND IN THE ÃOMMODORE 64 AND ÃOMMODORE 128 THAT ARE JUST NOW BEING REVEALED. ÉN THE EVENT THAT AN ARTICLE IS SUBMITTED AND THERE IS A QUESTION ABOUT IT'S ABILITY TO BE APPLIED TOWARDS ILLEGAL ACTIVITES, THE ARTICLE WILL BE CARRIED WITH A WARNING THAT THE INTENT IS NOT TOWARDS THAT ACTIVITY. ÈOPEFULLY, THESE WILL NEVER COME ALONG. :-) ÔHE ÃOMMODORE 64 CAME OUT IN LATE 1982 (É BELIEVE) AND WAS KNOWN TO ONLY SUPPORT 16 COLORS, 320 X 200 RESOLUTION GRAPHICS OF 2 COLORS, 160X200 RESOLUTION GRAPHICS OF 4 COLORS. ÓINCE THEN PEOPLE HAVE PUSHED THE ÃOMMODORE 64 TO ITS LIMITS WITH APPARENT RESOLUTION OF 320 X 200 WITH A RESOLUTION OF 4 COLORS AND EVEN HIGHER... MORE THAN 8 SPRITES ON THE SCREEN... FAST HIGH-QUALITY DIGITIZED SOUNDS.... ÔHE ÃOMMODORE 128 CAME OUT AS AN "UPGRADE" FROM THE ÃOMMODORE 64 AND WITH IT'S UNIQUE MEMORY MANAGEMENT SCHEME AND THE Ú80A CHIP STILL ON THERE PEOPLE ARE STILL FINDING OUT UNIQUE AND INTERESTING WAYS TO EXPLORE THE Ã=128. ÏNE OF THE MOST INTERESTING HAS BEEN THAT OF THE SEPERATE VIDEO DISPLAY CHIP WHICH MAKES IT POSSIBLE TO DISPALY 640X200 RESOLUTION GRAPHICS QUICKLY AND EASILY. **ÁÔÔÅÎÔÉÏÎ** ÔHIS MAGAZINE IS GOING TO BE A SOURCEBOOK OF MANY PEOPLE - ÉF YOU KNOW ANYTHING ABOUT SOMETHING, PLEASE FEEL FREE TO SUBMIT IT. ÊUST MAIL THE ARTICLE TO THE FOLLOWING : DUCK@PEMBVAX1.PEMBROKE.EDU AND A SUBJECT OF "ÁÒÔÉÃÌÅ - " AND THEN THE ARTICLE NAME. ÔHE SOURCE CODE FOR ALL PROGRAMS MENTIONED WITHIN ARTICLES WILL BE PROVIDED AS WELL AS ANY EXECUTABLES UUENCODED SENT OUT SEPRATELY. [ÅD. ÎOTE - ÉN THIS ISSUE, THE SOURCE IS NOT SENT SEPERATELY DUE TO ONLY ONE ARTICLE WITH FILES] ÉN ADDITION, THE MAGAZINE WILL GO OUT WHEN THERE ARE ENOUGH ARTICLES COLLECTED. ÁLSO, É'M CURRENTLY IN COLLEGE - SO - IT WILL ALSO BE DEPENDANT ON FEW TESTS ETC BEING AROUND THE RELEASE PERIOD. ÉN THIS ISSUE: ÔITLE ÁUTHOR(S) ------------------------------------------------------------------------------ ÈACKING - ÄEFINITION ÏF DUCK@PEMBVAX1.PEMBROKE.EDU ÌEARNING ÍÌ - ÐART 1 DUCK@PEMBVAX1.PEMBROKE.EDU 6502 ËNOWN/ÕNKNOWN ÏPCODES COMPILATION OF SEVERAL ÄOT ÐLOTTING & ÂITMAPPING F2RX@JUPITER.SUN.CSD.UNB.CA THE 8563 ÓCREEN. ** ÁLL ARTICLES AND FILES (Ã) 1992 BY THEIR RESPECTIVE AUTHORS. ============================================================================= ÂEGINNING ÍÌ - ÐART ÏNE (Ã) 1992 BY ÃRAIG ÔAYLOR ÔHE BEST WAY TO LEARN MACHINE LANGUAGE IS TO ACTUALLY CODE ROUTINES THAT YOU DON'T THINK WILL WORK, HOPE THAT THEY WORK, AND THEN FIGURE OUT WHY THEY DON'T WORK. (ÉF THEY DO WORK, YOU TRY TO FIGURE OUT WHY YOU DIDN'T THINK THEY'D WORK). ÉE: ÔÈÅ ÂÅÓÔ ×ÁÙ ÔÏ ÌÅÁÒÎ ÁÎÙ ÐÒÏÇÒÁÍÍÉÎÇ ÌÁÎÇÕÁÇÅ ÉÓ ÔÏ ÐÒÏÇÒÁÍ ÉÎ ÔÈÁÔ ÌÁÎÇÕÁÇÅ. ÁND ÍACHINE ÌANGUAGE IS A PROGRAMMING LANGUAGE. ÎOW, LET'S GET A FEW TERMS AND DEFINITIONS OUT OF THE WAY: ÍACHINE ÌANGUAGE - ÉNSTRUCTIONS THAT THE COMPUTER UNDERSTANDS AT A PRIMITIVE LEVEL AND EXECUTES ACCORDINGLY. ÁSSEMBLY ÌANGUAGE - ÉNSTRUCTIONS MORE UNDERSTANDABLE TO HUMANS THAN PURE ÍACHINE ÌANGUAGE THAT MAKES LIFE EASIER. ÁSSEMBLY: ÍACHINE: ÅXAMPLE: LDA #$00 $Á9 $00 ÈUH? YOU MIGHT BE SAYING AT THE MOMENT. ÔURNS OUT THAT ÌÄÁ STANDS FOR, OR IS A MNEMONIC (COMPUTER PEOPLE ALWAYS COME UP WITH THESE BIG LONG WORDS -- YOU'LL SEE MNEMONIC'S OFTEN WHEN DEALING WITH MACHINE LANGUAGE) FOR THE FOLLOWING: "ÌÏÁÄ REGISTER Á WITH THE FOLLOWING VALUE" ^ ^ ^ ÃOOL 'EH? ÙEAH, BUT THERE'S SOMEBODY GRUMBLING NOW ABOUT WHY NOT MAKE IT ÌÏÁÄÁ ETC.. ÈEY, THAT'S LIFE. (ÇÒÉÎ). ÏH, MORE DEFINITIONS: ÒEGISTER - Á LOCATION INSIDE THE ÃÐÕ THAT CAN BE MANIPULATED DIRECTLY WITHOUT HAVING TO ACCESS MEMORY. ÔHE "Á" REGISTER IS OFTEN CALLED THE ACCUMALATOR WHICH INDICATES ITS FUNCTION: ALL MATH AND LOGICAL MANIPULATIONS ARE DONE TO THE "Á" REGISTER (FROM HEREON OUT IT WILL BE REFERRED TO AS .Á). ÔHERE ARE TWO OTHER REGISTERS INSIDE THE 6502 PROCESSOR, SPECIFICALLY .Ø AND .Ù. ÔHESE REGISTERS HELP ACT AS COUNTERS AND INDEXES INTO MEMORY (SORTA LIKE MEM[X] IN PASCAL BUT NOT QUITE...). ÎOW, LET'S ADD 3 AND 5 AND LEAVE THE RESULT IN THE ACCUMALATOR (.Á). LDA #3 ; ÈERE .Á = 3 (ANYTHING W/ A ; IS A ; COMMENT AND WILL BE IGNORED BY THE ASSEMBLER... CLC ; HU? - ÔHIS CLEARS THE CARRY. ÔHE 6502 ; DOES ADDITION *EVERYTIME* WITH THE CARRY ... SO IF WE CLEAR IT IT WON'T ; AFFECT THE RESULT. ADC #5 ; ÎOW, .Á = .Á + 5 AND WE'RE DONE. ÉF THE ÃÌà CONFUSED YOU THEN CONSIDER THAT IF YOU'RE ADDING A COLUMN OF #'S: 12 <--\__ÔHE 2 + 9 = 11, BUT WE PUT THE 1 DOWN AND SET THE CARRY TO 1. + 89 <---/ -- 101 ÔHEN WE SAY 1 + 8 + CARRY , WHICH IN THIS CASE HAPPENS TO = 1 AND WE GET 10 AND AGAIN WE SET THE CARRY AND WRITE DOWN 0. ÔHEN IT'S JUST THE CARRY AND WE WRITE THAT DOWN. ÉF WE DIDN'T CLEAR THE CARRY WE MAY HAVE ENDED UP WITH THE VALUE OF 9 INSTEAD 8 IF THE CARRY HAD HAPPENED TO BE SET. ÁAAGH, ÍATH - ÌET'S CONTINUE - ÔHE ÃÌà MNEMONIC STANDS FOR "ÃÌÅÁÒ ÃÁÒÒÙ" AND THE ÁÄà STANDS FOR "ÁÄÄ WITH ÃÁÒÒÙ". ÏN MANY PROCESSORS THERE IS A ÁÄÄ (WITHOUT A CARRY) BUT UNFORTUNATELY THE 6502 PROCESSOR INSIDE THE Ã=64 DOESN'T HAVE IT. ÓO WE'VE GOT: LOAD REG Á WITH THE VALUE 5 LDA #5 CLEAR THE CARRY CLC ADD REG A AND VALUE 3 ADC #3 ÉN ÂASIC IT'S JUST: Á = 5+3 ÏNE STATEMENT... ÉN ÍACHINE ÌANGUAGE YOU'VE GOT TO BREAK EVERYTHING DOWN INTO SMALLER AND SMALLER STEPS AND QUITE OFTEN THE ÍÌ LISTING WILL BE FAR LONGER THAN THE ÂÁÓÉà OR ÐÁÓÃÁÌ OR à EQUIVLENT. ÄEFINITIONS: ÁSSEMBLER - ÐROGRAM TAKES SOURCE CODE IN BASIC FORM OR FROM A FILE AND WRITES TO MEMORY OR A FILE THE RESULTING EXECUTABLE. ÁLLOWS HIGHER FLEXIBILITY THAN A MONITOR (SEE BELOW) DUE TO USE OF LABELS ETC AND NOT HAVING TO KEEP TRACK OF EACH ADDRESS WITHIN THE PROGRAM. ÍONITOR - Á PROGRAM, RESIDENT IN MEMORY, INVOKED BY A SYS CALL FROM BASIC OR BY HITTING THE RESTORE KEY THAT WILL LET YOU DISASSEMBLE, ASSEMBLE AND EXAMINE AREAS OF MEMORY AND EXECUTE PROGRAMS DIRECTLY FROM THE MONITOR. ÕSEFUL FOR DEBUGGING PROGRAMS AND FOR WRITING SHORT PROGRAMS. ÌET'S ENTER THE FOLLOWING INTO A MONITOR (IF YOU DON'T HAVE ONE THEN CONTACT DUCK@PEMBVAX1.PEMBROKE.EDU AND É'LL SEND YA ONE): 128: C64: >A 1300 LDA #$93 >A C000 LDA #$93 >A 1302 JSR $FFD2 >A C003 JSR $FFD2 >A 1305 RTS >A C005 RTS (EXIT MONITOR) (EXIT MONITOR) BANK15:SYS4864 SYS 49152 ×OW! ÉT CLEARED THE SCREEN. ÎEAT 'EH? ÂUT SEE HOW MUCH YA GOTTA BREAK PROBLEMS DOWN? ÔHE FIRST STATEMENT LOADS IN $93 HEX INTO THE ACCUMALATOR ($93 HEX JUST HAPPENS TO EQUAL 147 WHICH IS ALSO THE ÃOMMODORSCII CODE FOR CLEAR SCREEN. ÆOR A WHOLE LIST JUST LOOK IN THE BACK OF THE BOOK THAT CAME WITH THE COMPUTER). ÔHEN WE JUMP TO A SYSTEM ROUTINE WHICH ÃOMMODORE SO GRACIOUSLY SUPPLIED US WITH THAT PRINTS THE VALUE OF THE CHARACTER IN .Á TO THE SCREEN. (JSR $FFD2) THEN WE DO A ÒÔÓ (ÒEÔURN FROM ÓUBROUTINE) SO THAT WE WILL GO BACK TO BASIC AND THE ÒEADY PROMPT WHEN WE ARE FINISHED WITH THE SYS CALL. ÙOU Ã= 128 PEOPLE MAY BE WONDERING WHY YOU HAD TO DO A BANK 15 AND ASSEMBLE THE STUFF AT A DIFFERENT MEMORY LOCATION. ÔURNS OUT THAT THE Ã128 MEMORY MAP OF WHERE ROUTINES ETC ARE AT IS MUCH MORE COMPLEX THAN THE Ã=64 AND THUS YOU HAVE TO TELL BASIC WHICH BANK YOU WISH TO HAVE ALL SYS, PEEK, AND POKE CALLS TO TAKE PLACE IN. ÁLSO, $C000 AS USED ON THE Ã=64 IS NOT AN AREA THAT IS FREE TO USE ON THE Ã128 IN THIS MANNER. ÁSSIGNMENT: ÔAKE A LOOK @ THE DIFFERENT COMMANDS AS LISTED IN 6502 ÏPCODES AND TRY TO UNDERSTAND WHAT THEY DO. ÅXPERIMENT WITH THE JSR $FFD2 ROUTINE BY USING DIFFERENT VALUES ETC. ÎEXT ÔIME: ÐRINTING OUT STRINGS, AND UNDERSTANDING 'ÉNDEXING'. =========================================================================== 6502 ÏPCODES AND ÑUASI-ÏPCODES. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ÔHE FOLLOWING TABLE LISTS ALL OF THE AVAILABLE OPCODES ON THE 65XX LINE OF MICRO-PROCESSORS (SUCH AS THE 6510 ON THE Ã=64 AND THE 8502 ON THE Ã=128) ----------------------------------------------------------------------------- ÓTD ÍNEMONIC ÈEX ÖALUE ÄESCRIPTION ÁDDRESSING ÍODE ÂYTES/ÔIME * ÂÒË $00 ÓTACK <- ÐÃ, Ðà <- ($FFFE) (ÉMMEDIATE) 1/7 * ÏÒÁ $01 Á <- (Á) Ö Í (ÉND,Ø) 6/2 ÊÁÍ $02 [LOCKS UP MACHINE] (ÉMPLIED) 1/- ÓÌÏ $03 Í <- (Í >> 1) + Á + à (ÉND,Ø) 2/8 ÎÏÐ $04 [NO OPERATION] (Ú-ÐAGE) 2/3 * ÏÒÁ $05 Á <- (Á) Ö Í (Ú-ÐAGE) 2/3 * ÁÓÌ $06 à <- Á7, Á <- (Á) << 1 (Ú-ÐAGE) 2/5 ÓÌÏ $07 Í <- (Í >> 1) + Á + à (Ú-ÐAGE) 2/5 * ÐÈÐ $08 ÓTACK <- (Ð) (ÉMPLIED) 1/3 * ÏÒÁ $09 Á <- (Á) Ö Í (ÉMMEDIATE) 2/2 * ÁÓÌ $0Á à <- Á7, Á <- (Á) << 1 (ÁCCUMALATOR) 1/2 ÁÎà $0 Á <- Á /\ Í, Ã=~Á7 (ÉMMEDIATE) 1/2 ÎÏÐ $0à [NO OPERATION] (ÁBSOLUTE) 3/4 * ÏÒÁ $0Ä Á <- (Á) Ö Í (ÁBSOLUTE) 3/4 * ÁÓÌ $0Å Ã <- Á7, Á <- (Á) << 1 (ÁBSOLUTE) 3/6 ÓÌÏ $0Æ Í <- (Í >> 1) + Á + à (ÁBSOLUTE) 3/6 * ÂÐÌ $10 IF Î=0, Ðà = Ðà + OFFSET (ÒELATIVE) 2/2'2 * ÏÒÁ $11 Á <- (Á) Ö Í ((ÉND),Ù) 2/5'1 ÊÁÍ $12 [LOCKS UP MACHINE] (ÉMPLIED) 1/- ÓÌÏ $13 Í <- (Í >. 1) + Á + à ((ÉND),Ù) 2/8'5 ÎÏÐ $14 [NO OPERATION] (Ú-ÐAGE,Ø) 2/4 * ÏÒÁ $15 Á <- (Á) Ö Í (Ú-ÐAGE,Ø) 2/4 * ÁÓÌ $16 à <- Á7, Á <- (Á) << 1 (Ú-ÐAGE,Ø) 2/6 ÓÌÏ $17 Í <- (Í >> 1) + Á + à (Ú-ÐAGE,Ø) 2/6 * ÃÌà $18 à <- 0 (ÉMPLIED) 1/2 * ÏÒÁ $19 Á <- (Á) Ö Í (ÁBSOLUTE,Ù) 3/4'1 ÎÏÐ $1Á [NO OPERATION] (ÉMPLIED) 1/2 ÓÌÏ $1Â Í <- (Í >> 1) + Á + à (ÁBSOLUTE,Ù) 3/7 ÎÏÐ $1à [NO OPERATION] (ÁBSOLUTE,Ø) 2/4'1 * ÏÒÁ $1Ä Á <- (Á) Ö Í (ÁBSOLUTE,Ø) 3/4'1 * ÁÓÌ $1Å Ã <- Á7, Á <- (Á) << 1 (ÁBSOLUTE,Ø) 3/7 ÓÌÏ $1Æ Í <- (Í >> 1) + Á + à (ÁBSOLUTE,Ø) 3/7 * ÊÓÒ $20 ÓTACK <- ÐÃ, Ðà <- ÁDDRESS (ÁBSOLUTE) 3/6 * ÁÎÄ $21 Á <- (Á) /\ Í (ÉND,Ø) 2/6 ÊÁÍ $22 [LOCKS UP MACHINE] (ÉMPLIED) 1/- ÒÌÁ $23 Í <- (Í << 1) /\ (Á) (ÉND,Ø) 2/8 * ÂÉÔ $24 Ú <- ~(Á /\ Í) Î<-Í7 Ö<-Í6 (Ú-ÐAGE) 2/3 * ÁÎÄ $25 Á <- (Á) /\ Í (Ú-ÐAGE) 2/3 * ÒÏÌ $26 à <- Á7 & Á <- Á << 1 + à (Ú-ÐAGE) 2/5 ÒÌÁ $27 Í <- (Í << 1) /\ (Á) (Ú-ÐAGE) 2/5'5 * ÐÌÐ $28 Á <- (ÓTACK) (ÉMPLIED) 1/4 * ÁÎÄ $29 Á <- (Á) /\ Í (ÉMMEDIATE) 2/2 * ÒÏÌ $2Á à <- Á7 & Á <- Á << 1 + à (ÁCCUMALATOR) 1/2 ÁÎà $2 Á <- Á /\ Í, à <- ~Á7 (ÉMMEDIATE9 1/2 * ÂÉÔ $2Ã Ú <- ~(Á /\ Í) Î<-Í7 Ö<-Í6 (ÁBSOLUTE) 3/4 * ÁÎÄ $2Ä Á <- (Á) /\ Í (ÁBSOLUTE) 3/4 * ÒÏÌ $2Å Ã <- Á7 & Á <- Á << 1 + à (ÁBSOLUTE) 3/6 ÒÌÁ $2Æ Í <- (Í << 1) /\ (Á) (ÁBSOLUTE) 3/6'5 * ÂÍÉ $30 IF Î=1, Ðà = Ðà + OFFSET (ÒELATIVE) 2/2'2 * ÁÎÄ $31 Á <- (Á) /\ Í ((ÉND),Ù) 2/5'1 ÊÁÍ $32 [LOCKS UP MACHINE] (ÉMPLIED) 1/- ÒÌÁ $33 Í <- (Í << 1) /\ (Á) ((ÉND),Ù) 2/8'5 ÎÏÐ $34 [NO OPERATION] (Ú-ÐAGE,Ø) 2/4 * ÁÎÄ $35 Á <- (Á) /\ Í (Ú-ÐAGE,Ø) 2/4 * ÒÏÌ $36 à <- Á7 & Á <- Á << 1 + à (Ú-ÐAGE,Ø) 2/6 ÒÌÁ $37 Í <- (Í << 1) /\ (Á) (Ú-ÐAGE,Ø) 2/6'5 * ÓÅà $38 à <- 1 (ÉMPLIED) 1/2 * ÁÎÄ $39 Á <- (Á) /\ Í (ÁBSOLUTE,Ù) 3/4'1 ÎÏÐ $3Á [NO OPERATION] (ÉMPLIED) 1/2 ÒÌÁ $3Â Í <- (Í << 1) /\ (Á) (ÁBSOLUTE,Ù) 3/7'5 ÎÏÐ $3à [NO OPERATION] (ÁBSOLUTE,Ø) 3/4'1 * ÁÎÄ $3Ä Á <- (Á) /\ Í (ÁBSOLUTE,Ø) 3/4'1 * ÒÏÌ $3Å Ã <- Á7 & Á <- Á << 1 + à (ÁBSOLUTE,Ø) 3/7 ÒÌÁ $3Æ Í <- (Í << 1) /\ (Á) (ÁBSOLUTE,Ø) 3/7'5 * ÒÔÉ $40 Ð <- (ÓTACK), Ðà <-(ÓTACK) (ÉMPLIED) 1/6 * ÅÏÒ $41 Á <- (Á) \-/ Í (ÉND,Ø) 2/6 ÊÁÍ $42 [LOCKS UP MACHINE] (ÉMPLIED) 1/- ÓÒÅ $43 Í <- (Í >> 1) \-/ Á (ÉND,Ø) 2/8 ÎÏÐ $44 [NO OPERATION] (Ú-ÐAGE) 2/3 * ÅÏÒ $45 Á <- (Á) \-/ Í (Ú-ÐAGE) 2/3 * ÌÓÒ $46 à <- Á0, Á <- (Á) >> 1 (ÁBSOLUTE,Ø) 3/7 ÓÒÅ $47 Í <- (Í >> 1) \-/ Á (Ú-ÐAGE) 2/5 * ÐÈÁ $48 ÓTACK <- (Á) (ÉMPLIED) 1/3 * ÅÏÒ $49 Á <- (Á) \-/ Í (ÉMMEDIATE) 2/2 * ÌÓÒ $4Á à <- Á0, Á <- (Á) >> 1 (ÁCCUMALATOR) 1/2 ÁÓÒ $4 Á <- [(Á /\ Í) >> 1] (ÉMMEDIATE) 1/2 * ÊÍÐ $4à Ðà <- ÁDDRESS (ÁBSOLUTE) 3/3 * ÅÏÒ $4Ä Á <- (Á) \-/ Í (ÁBSOLUTE) 3/4 * ÌÓÒ $4Å Ã <- Á0, Á <- (Á) >> 1 (ÁBSOLUTE) 3/6 ÓÒÅ $4Æ Í <- (Í >> 1) \-/ Á (ÁBSOLUTE) 3/6 * ÂÖà $50 IF Ö=0, Ðà = Ðà + OFFSET (ÒELATIVE) 2/2'2 * ÅÏÒ $51 Á <- (Á) \-/ Í ((ÉND),Ù) 2/5'1 ÊÁÍ $52 [LOCKS UP MACHINE] (ÉMPLIED) 1/- ÓÒÅ $53 Í <- (Í >> 1) \-/ Á ((ÉND),Ù) 2/8 ÎÏÐ $54 [NO OPERATION] (Ú-ÐAGE,Ø) 2/4 * ÅÏÒ $55 Á <- (Á) \-/ Í (Ú-ÐAGE,Ø) 2/4 * ÌÓÒ $56 à <- Á0, Á <- (Á) >> 1 (Ú-ÐAGE,Ø) 2/6 ÓÒÅ $57 Í <- (Í >> 1) \-/ Á (Ú-ÐAGE,Ø) 2/6 * ÃÌÉ $58 É <- 0 (ÉMPLIED) 1/2 * ÅÏÒ $59 Á <- (Á) \-/ Í (ÁBSOLUTE,Ù) 3/4'1 ÎÏÐ $5Á [NO OPERATION] (ÉMPLIED) 1/2 ÓÒÅ $5Â Í <- (Í >> 1) \-/ Á (ÁBSOLUTE,Ù) 3/7 ÎÏÐ $5à [NO OPERATION] (ÁBSOLUTE,Ø) 3/4'1 * ÅÏÒ $5Ä Á <- (Á) \-/ Í (ÁBSOLUTE,Ø) 3/4'1 ÓÒÅ $5Æ Í <- (Í >> 1) \-/ Á (ÁBSOLUTE,Ø) 3/7 * ÒÔÓ $60 Ðà <- (ÓTACK) (ÉMPLIED) 1/6 * ÁÄà $61 Á <- (Á) + Í + à (ÉND,Ø) 2/6 ÊÁÍ $62 [LOCKS UP MACHINE] (ÉMPLIED) 1/- ÒÒÁ $63 Í <- (Í >> 1) + (Á) + à (ÉND,Ø) 2/8'5 ÎÏÐ $64 [NO OPERATION] (Ú-ÐAGE) 2/3 * ÁÄà $65 Á <- (Á) + Í + à (Ú-ÐAGE) 2/3 * ÒÏÒ $66 Ã<-Á0 & Á<- (Á7=à + Á>>1) (Ú-ÐAGE) 2/5 ÒÒÁ $67 Í <- (Í >> 1) + (Á) + à (Ú-ÐAGE) 2/5'5 * ÐÌÁ $68 Á <- (ÓTACK) (ÉMPLIED) 1/4 * ÁÄà $69 Á <- (Á) + Í + à (ÉMMEDIATE) 2/2 * ÒÏÒ $6Á Ã<-Á0 & Á<- (Á7=à + Á>>1) (ÁCCUMALATOR) 1/2 ÁÒÒ $6 Á <- [(Á /\ Í) >> 1] (ÉMMEDIATE) 1/2'5 * ÊÍÐ $6à Ðà <- ÁDDRESS (ÉNDIRECT) 3/5 * ÁÄà $6Ä Á <- (Á) + Í + à (ÁBSOLUTE) 3/4 * ÒÏÒ $6Å Ã<-Á0 & Á<- (Á7=à + Á>>1) (ÁBSOLUTE) 3/6 ÒÒÁ $6Æ Í <- (Í >> 1) + (Á) + à (ÁBSOLUTE) 3/6'5 * ÂÖÓ $70 IF Ö=1, Ðà = Ðà + OFFSET (ÒELATIVE) 2/2'2 * ÁÄà $71 Á <- (Á) + Í + à ((ÉND),Ù) 2/5'1 ÊÁÍ $72 [LOCKS UP MACHINE] (ÉMPLIED) 1/- ÒÒÁ $73 Í <- (Í >> 1) + (Á) + à ((ÉND),Ù) 2/8'5 ÎÏÐ $74 [NO OPERATION] (Ú-ÐAGE,Ø) 2/4 * ÁÄà $75 Á <- (Á) + Í + à (Ú-ÐAGE,Ø) 2/4 * ÒÏÒ $76 Ã<-Á0 & Á<- (Á7=à + Á>>1) (Ú-ÐAGE,Ø) 2/6 ÒÒÁ $77 Í <- (Í >> 1) + (Á) + à (Ú-ÐAGE,Ø) 2/6'5 * ÓÅÉ $78 É <- 1 (ÉMPLIED) 1/2 * ÁÄà $79 Á <- (Á) + Í + à (ÁBSOLUTE,Ù) 3/4'1 ÎÏÐ $7Á [NO OPERATION] (ÉMPLIED) 1/2 ÒÒÁ $7Â Í <- (Í >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D 1 IF BRANCH SUCCEEDS, OR 2 IF INTO ANOTHER PAGE. '3 - ÉF PAGE BOUNDRY CROSSED THEN ÐÃÈ+1 IS JUST ÐÃÈ '4 - ÓOURCES DISPUTED ON EXACT OPERATION, OR SOMETIMES DOES NOT WORK. '5 - ÆULL EIGHT BIT ROTATION (WITH CARRY) ÓOURCES: ÐROGRAMMING THE 6502, ÒODNEY ÚAKS, (C) 1983 ÓYBEX ÐAUL ÏJALA, ÐOST TO ÃOMP.ÓYS.ÃBM (PO87553@CS.TUT.FI / ALBERT@CC.TUT.FI) Ä ÊOHN ÍCKENNA, ÐOST TO ÃOMP.ÓYS.ÃBM (GUDJM@UNIWA.UWA.OZ.AU) ÃOMPILED BY ÃRAIG ÔAYLOR (DUCK@PEMBVAX1.PEMBROKE.EDU) ============================================================================== ÓIMPLE ÈIRES ÌINE ÄRAWING ÐACKAGE FOR THE Ã-128 80-ÃOLUMN ÓCREEN ÃOPYRIGHT (C) 1992 ÃRAIG ÂRUCE 1. ÇÒÁÐÈÉÃÓ ÐÁÃËÁÇÅ ÏÖÅÒÖÉÅ× ÔHE GRAPHICS PACKAGE THIS ARTICLE EXPLAINS IS ÂÌÏÁÄED INTO MEMORY AT ADDRESS $1300 ON BANK 15 AND HAS THREE ENTRY POINTS: $1300 = MOVE THE PIXEL CURSOR OR DRAW A LINE: .ÁØ=X, .Ù=Y, .Ã=CMD $1303 = ACTIVATE GRAPHICS MODE AND CLEAR THE SCREEN $1306 = EXIT GRAPHICS MODE AND RELOAD THE CHARACTER SET ÔO MOVE THE PIXEL CURSOR TO THE START POINT OF A LINE, LOAD THE .ÁØ REGISTERS WITH THE Ø COORDINATE (0-639), LOAD THE .Ù REGISTER WITH THE Ù COORDINATE (0-199), CLEAR THE CARRY FLAG, AND CALL $1300. (ÍAKE SURE THAT ÂANK 15 IS IN CONTEXT). ÔHIS CAN BE DONE IN ÂÁÓÉà AS FOLLOWS: ÓÙÓ 4864, Ø ÁÎÄ 255, Ø/256, Ù, 0 ÔO DRAW A LINE FROM THE PIXEL CURSOR LOCATION TO A GIVEN POINT, LOAD THE .ÁØ AND .Ù REGISTERS LIKE BEFORE, SET THE CARRY FLAG, AND CALL $1300. ÔHE PIXEL CURSOR WILL THEN BE SET TO THE END POINT OF THE LINE JUST DRAWN, SO YOU DO NOT HAVE TO SET IT AGAIN IF YOU ARE DRAWING A CONTINUOUS OBJECT (LIKE A SQUARE). ÓÙÓ 4864, Ø ÁÎÄ 255, Ø/256, Ù, 1 ÔHE ACTIVATE AND EXIT ROUTINES ARE CALLED WITHOUT ANY PARAMETERS AND WORK VERY SIMPLY. ÙOU SHOULD BE SURE TO CALL EXIT BEFORE RETURNING TO THE PROGRAM EDITING MODE OR YOU WILL NOT BE ABLE TO SEE WHAT YOU ARE TYPING. Á ÂÁÓÉà DEMONSTRATION PROGRAM IS ALSO INCLUDED IN THE ÕÕ SECTION FOR THIS PACKAGE. ÉT STARTS BY PUTTING THE PIXEL CURSOR AT THE CENTER OF THE SCREEN AND THEN PICKS A RANDOM POINT TO DRAW TO, AND REPEATS UNTIL YOU PRESS A KEY TO STOP IT. ÆOR AN INTERESTING EFFECT, PUT A CALL TO $1303 IMMEDIATELY BEFORE THE CALL TO DRAW THE LINE. ÔHE POINT PLOTTING SPEED IS ABOUT 4,100 PIXELS PER SECOND AND THE LINE DRAWING SPEED IS A BIT SLOWER THAN THIS BECAUSE OF ALL OF THE CALCULATIONS THAT HAVE TO BE DONE TO DRAW A LINE. ÔHERE ARE FASTER PIXEL PLOTTING AND LINE DRAWING ALGORITHMS THAN THE ONES IMPLEMENTED HERE, BUT THAT IS MATERIAL FOR A FUTURE ARTICLE. 2. ÉÎÔÒÏÄÕÃÔÉÏÎ ÔÏ ÔÈÅ ÖÄà ÐROGRAMMING THE 8563 ÖIDEO ÄISPLAY ÃONTROLLER IS QUITE STRAIGHT FORWARD. ÙOU ACCESS IT A BIT INDIRECTLY, BUT IT CAN STILL BE DONE AT RELATIVELY HIGH SPEEDS USING MACHINE LANGUAGE. ÔHE ÖÄà CONTAINS 37 CONTROL REGISTERS AND FROM 16Ë TO 64Ë OF DEDICATED DISPLAY MEMORY THAT IS SEPARATE FROM THE MAIN PROCESSOR. ÔHE MEMORY MUST BE ACCESSED THROUGH THE ÖÄà REGISTERS. ÔHE IMPORTANT ÖÄà REGISTERS FOR THIS EXERCISE ARE: ÒÅÇ ÂÉÔÓ ÄÅÓà --- ---- ---- $12 7-0 ÖÄà ÒÁÍ ADDRESS HIGH BYTE $13 7-0 ÖÄà ÒÁÍ ADDRESS LOW BYTE $18 7 ÂLOCK COPY / BLOCK FILL MODE SELECT $19 7 ÂITMAP / ÃHARACTER MODE SELECT $19 6 ÃOLOR / ÍONOCHROME MODE SELECT $1A 7-4 ÆOREGROUND COLOR $1A 3-0 ÂACKGROUND COLOR $1E 7-0 ÃOPY / FILL REPETITION COUNT $1F 7-0 ÖÄà ÒÁÍ DATA READ / WRITE ÙOU ACCESS THE ÖÄà CHIP REGISTERS THOUGH ADDRESSES $ÄÆ00 AND $ÄÆ01 ON BANK 15. ÌOCATION $ÄÆ00 SELECTS THE ÖÄà REGISTER TO USE ON WRITE AND RETURNS THE ÖÄà STATUS ON READ. ÔHE ONLY IMPORTANT STATUS INFORMATION IS BIT 7 (VALUE $80) WHICH IS THE "READY" FLAG. ÔHE FOLLOWING TWO SUBROUTINES READ OR WRITE THE VALUE IN .Á TO ÖÄà REGISTER NUMBER .Ø: ÖDCÒEAD: STX $DF00 ÖDC×RITE: STX $DF00 ×AITÌOOP: BIT $DF00 ×AITÌOOP: BIT $DF00 BPL ×AITÌOOP BPL ×AITÌOOP LDA $DF01 STA $DF01 RTS RTS ÏNCE THE CURRENT ÖÄà REGISTER IS SELECTED AT $DF00, IT REMAINS SELECTED. ÙOU MAY READ OR WRITE IT THOUGH $DF01 AS MANY TIMES AS YOU LIKE AS LONG AS YOU WAIT FOR THE ÖÄà TO BE "READY" BETWEEN ACCESSES. ÉN ORDER TO ACCESS THE ÖÄà ÒÁÍ, YOU MUST FIRST PUT THE HIGH AND LOW BYTES OF THE ÖÄà ÒÁÍ ADDRESS INTO REGISTERS $12 AND $13 (HIGH BYTE FIRST) AND THEN READ OR WRITE THROUGH REGISTER $1F TO READ OR WRITE THE DATA IN THE ÖÄà ÒÁÍ. ÁFTER EACH ACCESS TO REGISTER $1F, THE ÖÄà ÒÁÍ ADDRESS IS INCREMENTED BY ONE. ÓO, IF YOU REPEATEDLY READ OR WRITE TO REGISTER $1F YOU CAN READ OR WRITE A CHUNK OF ÖÄà MEMORY VERY QUICKLY. 3. ÅÎÔÅÒÉÎÇ ÇÒÁÐÈÉÃÓ ÍÏÄÅ ÁCTIVATING THE GRAPHICS MODE OF THE ÖÄà IS VERY SIMPLE - YOU JUST HAVE TO SET BIT 7 OR ÖÄà REGISTER $19 AND POOF! ÙOU SHOULD ALSO CLEAR BIT 6 OF THAT REGISTER TO DISABLE THE CHARACTER COLOR MODE. ÔHIS GRAPHICS PACKAGE SUPPORTS ONLY MONOCHROME GRAPHICS SINCE THE STANDARD 16Ë ÖÄà DOES NOT HAVE ENOUGH SPACE TO HOLD BOTH THE BITMAP AND THE 8*8 PIXEL CELL ATTRIBUTES. ÔHE 640*200 PIXEL DISPLAY TAKES 128,000 BITS OR 16,000 BYTES. ÔHIS LEAVES 384 BYTES OF ÖÄà ÒÁÍ THAT IS NOT NEEDED BY THE BITMAP BUT IT IS NOT LARGE ENOUGH TO DO ANYTHING WITH, SO IT IS WASTED. ×HEN YOU DISABLE THE CHARACTER COLOR MODE, THE ÖÄà TAKES ITS FOREGROUND AND BACKGROUND COLOR VALUES FROM REGISTER $1A. ÔHE FOREGROUND COLOR IS WHAT COLOR THE "1" BITS IN THE BITMAP WILL BE DISPLAYED IN AND THE BACKGROUND COLOR, THE "0" BITS. ÎOW THAT THE BITMAP MODE IS SET UP, WE MUST CLEAR THE ÖÄà MEMORY LOCATIONS 0 TO 15999 (DECIMAL) TO CLEAR THE BITMAP SCREEN. ÔHIS CAN BE DONE VERY QUICKLY USING THE ÖÄà FILL MODE. ÉF YOU POKE A VALUE INTO ÖÄà REGISTER NUMBER $1E, THE ÖÄà WILL FILL ITS MEMORY FROM THE LOCATION CURRENTLY IN THE ÖÄà ÒÁÍ ADDRESS REGISTERS FOR THE NUMBER OF BYTES YOU JUST POKED INTO REGISTER $1E WITH THE VALUE THAT YOU LAST POKED INTO THE ÖÄà ÒÁÍ DATA REGISTER. (ÔHIS IS ASSUMING THAT "FILL" MODE IS SELECTED IN REGISTER $18). ÉF YOU POKE A 0 INTO THE REPEAT REGISTER IT MEANS TO FILL 256 BYTES. ÓO, TO CLEAR THE BITMAP, POKE A ZERO INTO BOTH OF THE ÖÄà ÒÁÍ ADDRESS REGISTERS SINCE THE BITMAP STARTS AT LOCATION 0. ÔHEN POKE A VALUE OF 0 INTO ÖÄà ÒÁÍ DATA REGISTER. ÔHIS SETS THE FILL VALUE TO 0 AND POKES THE FIRST ÖÄà ÒÁÍ LOCATION. ÔHEN, GO INTO A LOOP AND PUT A ZERO INTO THE ÖÄà REPEAT REGISTER 63 TIMES. ÔHIS WILL FILL 63 CONTIGUOUS CHUNKS OF 256 BYTES EACH. ×E END UP FILLING 16,129 BYTES, BUT THAT IS NOT A PROBLEM SINCE WE HAVE 384 "SAFETY" BYTES AT THE END OF THE BITMAP. ÉNTERNALLY, THE ÖÄà WILL FILL ITS MEMORY AT A RATE OF ABOUT 1 ÍEGABYTE PER SECOND (IF É REMEMBER MY TEST RESULTS CORRECTLY), SO CLEARING THE SCREEN IS A ÐÄÑ OPERATION. 4. ÅØÉÔÉÎÇ ÇÒÁÐÈÉÃÓ ÍÏÄÅ ÔO EXIT FROM GRAPHICS MODE WE HAVE TO RELOAD THE CHARACTER SET FROM THE ÒÏÍ ON BANK 14 AND WE HAVE TO GO BACK INTO CHARACTER MODE AND CLEAR THE TEXT SCREEN. ÔHE KERNEL PROVIDES ITS OWN CHARACTER RELOAD ROUTINE SO É USED THAT. ÔHE ONLY PROBLEM WITH IT IS THAT IT IS A LOT SLOWER THAN IT HAS TO BE. ÉT TAKES ABOUT 0.45 SECONDS WHEREAS THE SAME JOB CAN BE DONE IN ABOUT 0.09 SECONDS. ÔHE KERNEL IS SO SLOW BECAUSE IT USES THE KERNEL ÉÎÄÆÅÔÃÈ NONSENSE. ÔHEN YOU JUST SET THE BITMAP MODE BIT TO ZERO AND THE CHARACTER COLOR MODE TO ONE. ÔHIS GETS YOU BACK TO NORMAL CHARACTER MODE. ÙOU ALSO HAVE TO CLEAR THE TEXT SCREEN SINCE IT WILL BE FILLED WITH GARBAGE FROM THE GRAPHING. 5. ÐÏÉÎÔ ÐÌÏÔÔÉÎÇ ÔHE PIXELS ON THE SCREEN ACCESSED BY THEIR Ø AND Ù COORDINATES, 0 <= Ø <= 639, 0 <= Ù <= 199. ÔHE FORMULA TO CALCULATE THE BYTE ADDRESS IN THE ÖÄà ÒÁÍ GIVEN THE Ø AND Ù COORDINATES IS MADE SIMPLE BY THE MAPPING OF BYTES TO THE PIXELS ON THE SCREEN. ÔHE BYTES OF ÖÄà MEMORY GO ACROSS THE SCREEN RATHER THAN IN 8*8 CELLS LIKE THE ÖÉà SCREEN. ÅACH PIXEL ROW IS DEFINED BY 80 CONSECUTIVE BYTES OF ÖÄà ÒÁÍ. ÔHE FORMULA FOR THE BYTE ADDRESS OF A PIXEL IS: ÁÄ=Ù*80+ÉÎÔ(Ø/8), AND THE FORMULA FOR THE BIT NUMBER IS SIMPLY ÂÉ=Ø ÁÎÄ 7. ÔHE BIT NUMBER CAN BE USED AS AN INDEX INTO A TABLE OF BIT VALUES: [$80,$40,$20,$10,$08,$04,$02,$01], SUCH THAT INDEX 0 CONTAINS $80, SINCE THE HIGHEST BIT IS THE LEFTMOST BIT. ÃALCULATING THE BIT NUMBER AND LOOKING UP THE BIT VALUE IS VERY EASY TO DO IN MACHINE LANGUAGE, BUT THE BYTE ADDRESS CALCULATION REQUIRES A LITTLE MORE WORK. ÆIRST WE HAVE TO MULTIPLY THE Ù VALUE BY 80, USING A 16-BIT WORD FOR STORAGE. ÔHIS IS DONE BY SHIFTING THE Ù VALUE LEFT TWICE, ADDING THE ORIGINAL Ù VALUE, AND SHIFTING LEFT FOUR MORE TIMES. ÔHEN WE HAVE TO SHIFT THE Ø VALUE RIGHT BY THREE USING A 16-BIT WORD FOR STORAGE TO GET ÉÎÔ(Ø/8), AND WE ADD THE TWO RESULTS TOGETHER AND WE HAVE THE BYTE ADDRESS. ÔO PLOT THE POINT, WE HAVE TO PEEK INTO THE ÖÄà ÒÁÍ AT THE BYTE ADDRESS TO SEE WHAT IS "BEHIND" THE PIXEL WE WANT TO PLOT. ÔHEN ÏÒ THE NEW BIT VALUE ON TO THE "BACKGROUND" VALUE AND POKE THE RESULT BACK INTO ÖÄà ÒÁÍ AT THE BYTE ADDRESS. ÕNFORTUNATELY, SINCE THE ÖÄà ÒÁÍ ADDRESS REGISTER AUTO-INCREMENTS AFTER EACH REFERENCE, WE WILL HAVE TO SET IT TWICE - ONCE FOR THE READ AND ONCE FOR THE WRITE. ÔHAT MEANS THAT THE ÖÄà REGISTERS HAVE TO BE ACCESSED SIX TIMES FOR EACH PIXEL. ÆORTUNATELY, THE ÖÄà OPERATES AT ITS HIGHEST SPEED IN MONOCHROME BITMAP MODE (IT HAS LESS WORK TO DO THAN IN COLOR CHARACTER MODE, SO IT IS ABLE TO PAY MORE ATTENTION TO THE ÃÐÕ). ÅFFECTS OTHER THAN JUST PLOTTING THE POINT CAN BE ACHIEVED BY USING FUNCTIONS OTHER THAN ÏÒ TO PUT THE POINT ON THE BACKGROUND. ÅÏÒ WOULD "FLIP" THE PIXEL, AND ÁÎÄ-ÎÏÔ (ACHIEVED BY ÌÄÁ BITVAL : ÅÏÒ #$FF : ÁÎÄ BACKGROUND) WOULD ERASE THE PIXEL. 6. ÌÉÎÅ ÄÒÁ×ÉÎÇ ÔHE LINE DRAWING ROUTINE THAT IS IMPLEMENTED IN THE PACKAGE IS GIVEN BY THE FOLLOWING ÂÁÓÉà CODE (IN FACT, É PROGRAMMED IT IN ÂÁÓÉà FIRST TO GET IT WORKING; OF COURSE, THE ÂÁÓÉà VERSION IS AS SLOW AS HELL): 10 DX=X-LX:DY=Y-LY 20 IF ABS(DX)>ABS(DY) THEN BEGIN R=DX:GY=DY/ABS(DX):GX=SGN(DX) 30 BEND:ELSE R=DY:GX=DX/ABS(DY):GY=SGN(DY) 40 PX=LX+0.5:PY=LY+0.5 50 FORI=1TO ABS(R): <ÐÌÏÔ ÐØ,ÐÙ> :PX=PX+GX:PY=PY+GY:NEXT 60 LX=X:LY=Y ÔHIS IMPLEMENTS THE ÂASIC ÉNCREMENTAL ÁLGORITHM FOR RASTER LINE DRAWING. ÔHE "LX" AND "LY" ARE THE POSITION OF THE PIXEL CURSOR AND "X" AND "Y" ARE THE COORDINATES TO DRAW THE LINE TO. ÔHE "DX" AND "DY" ARE THE DIFFERENCES IN THE Ø AND Ù DIRECTIONS. ÔHE IDEA IS THAT WE WILL INCREMENT THE PIXEL CURSOR BY A CONSTANT OF 1 IN ONE DIRECTION AND BY A FRACTION 0.0 <= G <= 1.0 IN THE OTHER DIRECTION. ÔHIS FRACTION IS ACTUALLY THE SLOPE OF THE LINE. ÌINES 20 AND 30 FIGURE OUT THE INCREMENTS FOR THE Ø AND Ù DIRECTIONS ("GX" AND "GY"). ÔHESE ARE SIGNED FRACTIONAL NUMBERS ON THE RANGE -1.0 <= G <= 1.0. ×E CHECK THE "DX" AND "DY" TO SEE WHICH HAS THE GREATEST ABSOLUTE VALUE AND THAT WILL BE THE DIRECTION THAT IS INCREMENTED BY 1, 0, OR -1 AND THE OTHER DIRECTION WILL INCREMENT BY THE (FRACTIONAL) SLOPE OF THE LINE WITH RESPECT TO THE OTHER DIRECTION. ÌINE 40 STARTS THE PLOTTING AT THE CURRENT PIXEL CURSOR LOCATION ÐÌÕÓ 0.5. ×E ADD 1/2 TO THE Ø AND Ù POSITIONS TO "CENTER" ONTO THE PIXEL CELL. ÉF WE DIDN'T DO THIS, WE WOULD NOTICE DIS-SYMMETRY IN PLOTTING TO THE LEFT AND TO THE RIGHT. ÆOR EXAMPLE, 50.0 - 0.3 = 49.7 AND 50.0 + 0.3 = 50.3. ÉF WE TRUNCATE THESE VALUES, GOING LEFT BY 0.3 MOVES US TO POSITION 49 WHEREAS GOING RIGHT BY 0.3 MAKES US STAY IN THE SAME POSITION. ÔHIS IS DIS-SYMMETRY AND MAKES PLOTS LOOK A BIT OFF. ÁDDING 0.5 CORRECTS THE PROBLEM. ÌINE 50 GOES INTO A LOOP FOR THE LONGEST DIMENSION OF THE LINE (THE ONE INCREMENTED BY 1). ÔHE <ÐÌÏÔ ÐØ,ÐÙ> IS NOT EXACTLY ÂÁÓÉÃ; YOU SUBSTITUTE THE CALL TO THE POINT PLOT ROUTINE DESCRIBED IN THE PREVIOUS SECTION. ÉT REPEATEDLY ADDS THE Ø AND Ù INCREMENT VALUES UNTIL THE LINE IS FINISHED. ÔHIS ALGORITHM DRAWS THE LINE IN THE DIRECTION THAT YOUR END POINTS IMPLY. 6.1. ÆÒÁÃÔÉÏÎÁÌ ÎÕÍÂÅÒ ÒÅÐÒÅÓÅÎÔÁÔÉÏÎ ÔHERE ARE ONLY TWO REAL COMPLICATIONS TO THE MACHINE LANGUAGE IMPLEMENTATION ARE THE REPRESENTATION OF THE SIGNED FRACTIONAL NUMBERS AND THE DIVISION OF THE FRACTIONAL NUMBERS. ÔO REPRESENT THE NUMBERS É USE A 32-BIT FORMAT WITH A 16-BIT SIGNED INTEGER PORTION (-32768 TO +32767) AND A 16-BIT FRACTIONAL PORTION (0.0 TO 0.99998474 IN 0.00001526 INCREMENTS). ÔHE WEIGHT VALUES OF THE BIT POSITIONS ARE AS FOLLOWS: ÐÏÓ 31 ... 22 21 20 19 18 17 16 15 14 13 12 11 10 9 ... 0 ÖÁÌ 32768 ... 64 32 16 8 4 2 1 1/2 1/4 1/8 1/16 1/32 1/64 1/128 ...1/65536 ÆOR EXAMPLE, 0...00001011101.10011010000...0 (NOTICE THE ÂÉÎÁÒÙ POINT) IS 64 + 16 + 8 + 4 + 1 + 1/2 + 1/16 + 1/32 + 1/128 = 93.6015625 IN DECIMAL. ÏR, AS A SHORT CUT, YOU CAN CONSIDER THE INTEGER 16 BITS AND THE FRACTIONAL 16 BITS AS INDEPENDENT WORDS AND ADD 1/65536TH OF THE SECOND TO THE FIRST. ÔHUS, FOR THE EXAMPLE ABOVE, THE QUANTITY IS 93 + (32768+4096+2048+512)/65536 = 93.6015625. (ÇOOD, THEY BOTH MATCH). ÔHE FIRST CALCULATION USES TRUE BASE 2 WHEREAS THE SECOND CALCULATION USES BASE 65536. ÔWO'S COMPLEMENT REPRESENTATION IS USED TO ACHIEVE SIGNEDNESS (,ÐARK!). ×E SHOULD ALL KNOW ABOUT TWO'S COMP. ×ELL, IT WORKS JUST FINE FOR FRACTIONAL BINARY NUMBERS AS WELL. ÉN FACT, IT MAKES NO DIFFERENCE AT ALL. ÙOU CAN JUST THINK OF THE QUANTITY AS AN INTEGER NUMBER OF 65536'S OF A PIXEL AND YOU GET THE INTEGER OPERATIONS OF COMPLEMENT, ADD, AND SUBTRACT FOR FREE. ÔHE EASY WAY TO GET THE TWO'S COMP. REPRESENTATION OF A NUMBER IS TO TAKE THE POSITIVE BINARY IMAGE OF THE NUMBER AND SUBTRACT IT FROM 0 (THIS MAKES PERFECT SENSE SINCE 0 - X = -X). ÆRACTIONAL BINARY DIVISION IS A LITTLE MORE COMPLICATED. ÔHERE IS NO PROBLEM WITH THE BINARY POINT, SINCE THE LAWS OF MATHEMATICS SAY WE CAN MULTIPLY THE TOP AND BOTTOM BY THE SAME QUANTITY (LIKE 65536) WITHOUT CHANGING THE RESULT, BUT HANDLING THE TWO'S COMPLEMENT IS A PROBLEM. ×HAT É DID WAS FIGURE OUT WHAT THE SIGN OF THE RESULT OF THE DIVISION WAS GOING TO BE (BY ÅÏÒING THE SIGN BITS TOGETHER) AND THEN CONVERTED THE TWO OPERANDS TO THEIR POSITIVE VALUE IF THEY WERE ORIGINALLY NEGATIVE. ÔHIS LETS ME PERFORM A 32-BIT UNSIGNED DIVISION OPERATION AND THEN É CONVERT THE RESULT TO A NEGATIVE IF THE RESULT IS SUPPOSED TO BE NEGATIVE. ÔHE 32-BIT DIVIDE IS NOT ALL THAT COMPLICATED; IT IS DONE THE SAME WAY THAT YOU WOULD DO IT ON PAPER (REMEMBER THOSE DAYS) EXCEPT YOU USE BINARY DIGITS. ÔHE DIVIDE SUBROUTINE DOES NOT EXACTLY RIVAL SUPERCOMPUTER SPEEDS, BUT IT DOES GET THE JOB DONE. 6.2. ÍÁÃÈÉÎÅ ÌÁÎÇÕÁÇÅ ÏÐÅÒÁÔÉÏÎ ×HILE DRAWING THE LINE, THE Ø AND Ù COORDINATES ARE 32-BIT SIGNED FRACTIONAL NUMBERS AS WELL AS THE "GX" AND "GY" VECTOR COMPONENTS ("GO" VALUES). ÌINES 20 AND 30 REQUIRE QUITE A BIT OF WORK IN 6502 MACHINE LANGUAGE AND USE THE 32-BIT ADD, SUBTRACT, 2'S COMPLEMENT, AND DIVIDE OPERATIONS DESCRIBED IN THE PREVIOUS SECTION. ÔO FIND THE ÁÂÓOLUTE VALUE OF A NUMBER, CHECK TO SEE WHETHER IT IS POSITIVE OR NEGATIVE. ÉF IT IS POSITIVE, YOU ARE DONE. ÉF IT IS NEGATIVE, JUST DO A 2'S COMPLEMENT ON IT (MAKES SENSE: 0 - (-X) = X). ÌINE 40 IS DONE BY SIMPLY TAKING THE PIXEL CURSOR Ø AND Ù COORDINATES (WHICH ARE STORED AS UNSIGNED INTEGERS AND ARE REMEMBERED BETWEEN LINE DRAW CALLS) AND PUT THEM INTO THE HIGH WORD OF A 32-BIT FIELD AND THEN PUT $8000 (32768) INTO THE LOW WORD (WHICH GIVES Ö + 1/2). ÌINE 50 IS EASILY IMPLEMENTED AS A LOOP THAT DECREMENTS THE "R" WORD UNTIL IT REACHES ZERO, WHILE CALLING THE POINT PLOT ROUTINE AND DOING THE 32-BIT ADD TO ADD THE "G" VALUES TO THE Ø AND Ù COORDINATES. ×HEN THE LINE IS FINISHED, THE FINAL Ø AND Ù COORDINATES ARE PUT BACK INTO THE PIXEL CURSOR POSITION STORAGE AND THE PACKAGE IS READY FOR THE NEXT CALL. 7. ÃÏÎÃÌÕÓÉÏÎ ÈA! ÔHIS AIN'T NO FORMAL PAPER SO É DON'T HAVE TO WRITE A CONCLUSION. ÓO THERE! [ÅD.ÎOTE - ÈE IS CURRENTLY WORKING ON HIS ÍASTERS THESIS, SO YOU'LL HAVE TO PARDON 'EM HERE.. (GRIN) ] ================================================================================ ;***************************************************************************** ;* "ÈÉÒÅÓ80.ÂÉÎ" HIRES LINE PLOTTING PACKAGE FOR THE ÃOMMODORE 128 80-COL * ;* SCREEN. * ;* * ;* ÔHIS PACKAGE CONTAINS A COUPLE OF IRREGULARITIES THAT É DISCOVERED * ;* WHILE É WAS COMMENTING IT. É LEFT THEM IN RATHER THAN START ALL OVER, * ;* SINCE THIS PACKAGE WAS WRITTEN WITH A MONITOR RATHER THAN AN ASSEMBLER. * ;***************************************************************************** ;***************************************************************************** ;* PACKAGE ENTRY POINTS * ;***************************************************************************** .$1300 [4C 01 15] JMP $1501 ;JMP TO DRAW LINE/POSITION PIXEL CURSOR .$1303 [4C 11 13] JMP $1311 ;JMP TO ENTER HIRES MODE .$1306 [4C 48 13] JMP $1348 ;JMP TO EXIT HIRES MODE .$1309 [4C 10 13] JMP $1310 ;RESERVED .$130C [4C 10 13] JMP $1310 ;RESERVED .$130F: $B3 ;LIBRARY LOADED IDENTIFIER .$1310 [60 ] RTS ;***************************************************************************** ;* ENTER HIRES MODE * ;***************************************************************************** .$1311 [A9 00 ] LDA #$00 ;SWITCH TO BANK 15 (KERNAL BANK) .$1313 [8D 00 FF] STA $FF00 .$1316 [A9 E0 ] LDA #$E0 ;SET COLOR TO LIGHT GREY ON BLACK .$1318 [A2 1A ] LDX #$1A .$131A [20 CC CD] JSR $CDCC .$131D [A9 87 ] LDA #$87 ;ENTER BITMAP MODE (NOTE - FOR VERSION 2 ÖÄÃ) .$131F [A2 19 ] LDX #$19 .$1321 [20 CC CD] JSR $CDCC .$1324 [A9 00 ] LDA #$00 ;SET ÖÄà ÒÁÍ ADDRESS HIGH .$1326 [A2 12 ] LDX #$12 .$1328 [20 CC CD] JSR $CDCC .$132B [E8 ] INX ;SET ÖÄà ÒÁÍ ADDRESS LOW .$132C [20 CC CD] JSR $CDCC .$132F [A9 00 ] LDA #$00 ;SET ÖÄà ÒÁÍ DATA REGISTER TO $00 .$1331 [20 CA CD] JSR $CDCA .$1334 [A9 20 ] LDA #$20 ;SELECT BLOCK FILL MODE .$1336 [A2 18 ] LDX #$18 .$1338 [20 CC CD] JSR $CDCC .$133B [A9 00 ] LDA #$00 ;FILL 256*63 ÖÄà BYTES WITH 0 .$133D [A2 1E ] LDX #$1E ; TO CLEAR THE HIRES SCREEN .$133F [A0 3F ] LDY #$3F .$1341 [20 CC CD] JSR $CDCC .$1344 [88 ] DEY .$1345 [D0 FA ] BNE $1341 .$1347 [60 ] RTS ;***************************************************************************** ;* EXIT HIRES MODE * ;***************************************************************************** .$1348 [20 0C CE] JSR $CE0C ;RELOAD THE CHARACTER SETS .$134B [A9 93 ] LDA #$93 ;CLEAR THE TEXT SCREEN .$134D [20 D2 FF] JSR $FFD2 .$1350 [A2 19 ] LDX #$19 ;RESTORE COLOR TEXT MODE .$1352 [A9 47 ] LDA #$47 .$1354 [4C CC CD] JMP $CDCC ;***************************************************************************** ;*CALCULATE THE BITMAP BYTE ADDRESS AND BIT VALUE FOR PIXEL GIVEN X=.ÁØ,Y=.Ù * ;***************************************************************************** .$1357 [84 FA ] STY $FA ;SAVE .Á AND .Ù .$1359 [85 FC ] STA $FC .$135B [98 ] TYA ;PUT PIXEL CURSOR Y POSITION INTO .Á .$135C [A0 00 ] LDY #$00 ;CLEAR PIXEL CURSOR Y POSITION HIGH BYTE .$135E [84 FB ] STY $FB .$1360 [0A ] ASL A ;MULTIPLY PIXEL CURSOR Y BY 2 GIVING Y*2 .$1361 [26 FB ] ROL $FB ; AND WE MUST SHIFT THE HIGH BYTE TO .$1363 [0A ] ASL A ;AGAIN, GIVING Y*4 .$1364 [26 FB ] ROL $FB .$1366 [18 ] CLC ;ADD THE ORIGINAL Y, GIVING Y*5 .$1367 [65 FA ] ADC $FA .$1369 [90 02 ] BCC $136D .$136B [E6 FB ] INC $FB .$136D [0A ] ASL A ;MULTIPLY BY 2 AGAIN, GIVING Y*10 .$136E [26 FB ] ROL $FB .$1370 [0A ] ASL A ;AGAIN, GIVING Y*20 .$1371 [26 FB ] ROL $FB .$1373 [0A ] ASL A ;AGAIN, GIVING Y*40 .$1374 [26 FB ] ROL $FB .$1376 [0A ] ASL A ;AGAIN, GIVING Y*80: HA! WE ARE DONE .$1377 [26 FB ] ROL $FB .$1379 [85 FA ] STA $FA ;SAVE LOW BYTE OF Y*80 .$137B [A5 FC ] LDA $FC ;RESTORE X COORDINATE LOW BYTE .$137D [86 FD ] STX $FD ;SET UP X COORDINATE HIGH BYTE .$137F [46 FD ] LSR $FD ;DIVIDE THE X COORDINATE BY 2 GIVING X/2 .$1381 [6A ] ROR A ; WE MUST ROR THE HIGH BYTE, THEN THE LOW .$1382 [46 FD ] LSR $FD ;AGAIN, GIVING X/4 .$1384 [6A ] ROR A .$1385 [46 FD ] LSR $FD ;AGAIN, GIVING X/8: DONE .$1387 [6A ] ROR A .$1388 [18 ] CLC ;NOW ADD Y*80 AND X/8 .$1389 [65 FA ] ADC $FA .$138B [85 FA ] STA $FA .$138D [A5 FD ] LDA $FD .$138F [65 FB ] ADC $FB .$1391 [85 FB ] STA $FB ;GIVING US THE PIXEL BYTE ADDRESS IN ($FA) .$1393 [A5 FC ] LDA $FC ;GET X MOD 8 .$1395 [29 07 ] AND #$07 ; HA! WE CAN JUST EXTRACT THE LOW THREE BITS .$1397 [AA ] TAX .$1398 [BD 9E 13] LDA $139E,X ;LOOK UP THE BIT VALUE IN THE TABLE .$139B [85 FC ] STA $FC ; AND SAVE IT AT $FC .$139D [60 ] RTS ;EXIT WITH ADDRESS IN ($FA) AND VALUE IN $FC ;***************************************************************************** ;* BIT VALUE TABLE * ;***************************************************************************** .$139E: $80 $40 $20 $10 ;BIT VALUES STORED LEFT TO RIGHT .$13A2: $08 $04 $02 $01 .$13A6 [00 ] BRK ;FILLER - É FORGET WHY É PUT IT HERE .$13A7 [00 ] BRK ;***************************************************************************** ;* PLOT PIXEL AT X=.ÁØ, Y=.Ù ON BITMAP SCREEN * ;***************************************************************************** .$13A8 [20 57 13] JSR $1357 ;CALCULATE THE PIXEL ADDRESS AND VALUE .$13AB [A5 FB ] LDA $FB ;SET ÖÄà ÒÁÎ ADDRESS HIGH TO PIXEL ADDRESS .$13AD [A2 12 ] LDX #$12 .$13AF [20 CC CD] JSR $CDCC .$13B2 [A5 FA ] LDA $FA ;SET ÖÄà ÒÁÍ ADDRESS LOW TO PIXEL ADDRESS .$13B4 [E8 ] INX .$13B5 [20 CC CD] JSR $CDCC .$13B8 [20 D8 CD] JSR $CDD8 ;PEEK THE ÖÄà ÒÁÍ ADDRESS .$13BB [05 FC ] ORA $FC ;ÏÒ ON THE NEW PIXEL VALUE .$13BD [A8 ] TAY ; AND SAVE THE RESULT (BYTE TO POKE BACK) .$13BE [A5 FB ] LDA $FB ;RESET THE ÖÄà ÒÁÍ ADDRESS TO THE PIXEL .$13C0 [A2 12 ] LDX #$12 ; ADDRESS; THIS IS NECESSARY SINCE THE .$13C2 [20 CC CD] JSR $CDCC ; ÖÄà WILL INCREMENT ITS ÒÁÍ ADDRESS ON .$13C5 [A5 FA ] LDA $FA ; EVERY ACCESS .$13C7 [E8 ] INX .$13C8 [20 CC CD] JSR $CDCC .$13CB [98 ] TYA .$13CC [4C CA CD] JMP $CDCA ;AND POKE THE NEW PIXEL BYTE VALUE ;***************************************************************************** ;* PERFORM THE UNSIGNED 32-BIT DIVIDE WITH 16-BIT DENOMINATOR (BOTTOM) * ;* [$63 $62 $61 $60] IS THE NUMERATOR (TOP) * ;* [$51 $50] IS THE DENOMINATOR (BOTTOM) * ;* [$67 $66 $65 $64] IS THE QUOTIENT (RESULT) * ;* [$54 $53 $52] IS THE REMAINDER * ;***************************************************************************** .$13CF [A9 00 ] LDA #$00 ;SET THE RESULT TO 0 .$13D1 [85 64 ] STA $64 .$13D3 [85 65 ] STA $65 .$13D5 [85 66 ] STA $66 .$13D7 [85 67 ] STA $67 .$13D9 [85 52 ] STA $52 ;CLEAR THE REMAINDER .$13DB [85 53 ] STA $53 .$13DD [85 54 ] STA $54 .$13DF [A2 20 ] LDX #$20 ;SET THE LOOP COUNT TO 32 BITS .$13E1 [06 60 ] ASL $60 ;SHIFT OUT THE HIGH BIT OF THE NUMERATOR .$13E3 [26 61 ] ROL $61 .$13E5 [26 62 ] ROL $62 .$13E7 [26 63 ] ROL $63 .$13E9 [26 52 ] ROL $52 ;SHIFT IT INTO THE REMAINDER .$13EB [26 53 ] ROL $53 .$13ED [26 54 ] ROL $54 .$13EF [A5 54 ] LDA $54 ;CHECK IF THE REMAINDER IS >= THE DENOMINATOR .$13F1 [D0 0A ] BNE $13FD .$13F3 [A5 52 ] LDA $52 .$13F5 [C5 50 ] CMP $50 .$13F7 [A5 53 ] LDA $53 .$13F9 [E5 51 ] SBC $51 .$13FB [90 11 ] BCC $140E ;IF NOT, GO TO NEXT BIT .$13FD [38 ] SEC ;SUBRACT THE DENOMINATOR FROM THE REMAINDER .$13FE [A5 52 ] LDA $52 .$1400 [E5 50 ] SBC $50 .$1402 [85 52 ] STA $52 .$1404 [A5 53 ] LDA $53 .$1406 [E5 51 ] SBC $51 .$1408 [85 53 ] STA $53 .$140A [B0 02 ] BCS $140E .$140C [C6 54 ] DEC $54 .$140E [26 64 ] ROL $64 ;SHIFT A "1" BIT INTO THE DENOMINATOR. ÎOTE .$1410 [26 65 ] ROL $65 ; THE FIRST "ROL" SHOULD HAVE BEEN PRECEEDED .$1412 [26 66 ] ROL $66 ; BY A "SEC"; THIS IS A ÂÕÇ! ÈOWEVER, IT .$1414 [26 67 ] ROL $67 ; WILL FAIL ONLY IF DENOM >=32768 WHICH ; CANNOT HAPPEN IN THIS APPLICATION. .$1416 [CA ] DEX ;GO ON TO THE NEXT BIT .$1417 [D0 C8 ] BNE $13E1 .$1419 [60 ] RTS ;***************************************************************************** ;* GET THE ABSOLUTE VALUE OF THE 2'S COMP NUMBER IN .ÁÙ -> .ÁÙ * ;***************************************************************************** .$141A [84 50 ] STY $50 .$141C [A6 50 ] LDX $50 .$141E [10 10 ] BPL $1430 ;IF THE NUMBER IS POSITIVE, EXIT .$1420 [38 ] SEC ;ELSE TAKE THE 2'S COMPLEMENT OF THE NEGATIVE .$1421 [85 50 ] STA $50 ; VALUE TO GET THE POSITIVE VALUE .$1423 [A9 00 ] LDA #$00 .$1425 [E5 50 ] SBC $50 .$1427 [48 ] PHA .$1428 [84 50 ] STY $50 .$142A [A9 00 ] LDA #$00 .$142C [E5 50 ] SBC $50 .$142E [A8 ] TAY .$142F [68 ] PLA .$1430 [60 ] RTS ;***************************************************************************** ;* PERFORM THE FRACTIONAL SIGNED 32-BIT DIVIDE * ;***************************************************************************** .$1431 [48 ] PHA ;REMEMBER THE SIGN OF THE RESULT .$1432 [A9 00 ] LDA #$00 ;SET THE NUMERATOR FRACTIONAL PORTION TO .0 .$1434 [85 60 ] STA $60 .$1436 [85 61 ] STA $61 .$1438 [20 CF 13] JSR $13CF ;32-BIT DIVIDE .$143B [68 ] PLA ;IF THE SIGN OF THE RESULT IS SUPPOSED TO BE .$143C [10 19 ] BPL $1457 ; POSITIVE, THEN EXIT .$143E [38 ] SEC ;IF THE SIGN OF THE RESULT IS NEGATIVE, TAKE .$143F [A9 00 ] LDA #$00 ; GET THE 2'S COMPLEMENT OF THE POSITIVE .$1441 [E5 64 ] SBC $64 ; RESULT .$1443 [85 64 ] STA $64 .$1445 [A9 00 ] LDA #$00 .$1447 [E5 65 ] SBC $65 .$1449 [85 65 ] STA $65 .$144B [A9 00 ] LDA #$00 .$144D [E5 66 ] SBC $66 .$144F [85 66 ] STA $66 .$1451 [A9 00 ] LDA #$00 .$1453 [E5 67 ] SBC $67 .$1455 [85 67 ] STA $67 .$1457 [60 ] RTS ;***************************************************************************** ;* GET THE Ø AND Ù PLOTTING INCREMENTS AND THE PIXELS-TO-PLOT COUNT * ;***************************************************************************** .$1458 [A5 0C ] LDA $0C ;GET ÁÂÓ(ÄØ) .$145A [A4 0D ] LDY $0D .$145C [20 1A 14] JSR $141A .$145F [85 FA ] STA $FA .$1461 [84 FB ] STY $FB .$1463 [A5 10 ] LDA $10 ;GET ÁÂÓ(ÄÙ) .$1465 [A4 11 ] LDY $11 .$1467 [20 1A 14] JSR $141A .$146A [85 FC ] STA $FC .$146C [84 FD ] STY $FD .$146E [A5 FC ] LDA $FC ;COMPARE ÁÂÓ(ÄÙ) TO ÁÂÓ(ÄØ) .$1470 [C5 FA ] CMP $FA .$1472 [A5 FD ] LDA $FD .$1474 [E5 FB ] SBC $FB .$1476 [B0 44 ] BCS $14BC ;IF ÁÂÓ(ÄÙ) >= ÁÂÓ(ÄØ) THEN BRANCH AHEAD .$1478 [A5 FA ] LDA $FA ;SET PIXELS-TO-PLOT COUNT TO ÁÂÓ(ÄØ) .$147A [85 12 ] STA $12 .$147C [85 50 ] STA $50 .$147E [A5 FB ] LDA $FB .$1480 [85 13 ] STA $13 .$1482 [85 51 ] STA $51 ;SET THE NUMERATOR (TOP) TO ÄÙ AND THE .$1484 [A5 FC ] LDA $FC ; DENOMINATOR (BOTTOM) TO ÁÂÓ(ÄØ) .$1486 [85 62 ] STA $62 .$1488 [A5 FD ] LDA $FD .$148A [85 63 ] STA $63 .$148C [A5 11 ] LDA $11 ;GET THE SIGN OF ÄÙ - WILL BE THE SIGN OF DIV .$148E [20 31 14] JSR $1431 ;PERFORM THE SIGNED FRACTIONAL DIVISION .$1491 [A2 03 ] LDX #$03 ;STORE THE RESULT IN THE Ù INCREMENT VALUE .$1493 [B5 64 ] LDA $64,X .$1495 [95 0E ] STA $0E,X .$1497 [CA ] DEX .$1498 [10 F9 ] BPL $1493 .$149A [A5 0D ] LDA $0D ;GET THE Ø INCREMENT .$149C [30 0A ] BMI $14A8 .$149E [A9 00 ] LDA #$00 ;IF ÄØ IS POSITIVE, Ø INC IS +1 .$14A0 [85 0D ] STA $0D ; (NOTE THAT ÄØ CANNOT BE 0 HERE SO WE DON'T .$14A2 [A9 01 ] LDA #$01 ; HAVE TO WORRY ABOUT THAT CASE) .$14A4 [85 0C ] STA $0C .$14A6 [D0 06 ] BNE $14AE .$14A8 [A9 FF ] LDA #$FF ;IF ÄØ IS NEGATIVE, Ø INC IS -1 .$14AA [85 0D ] STA $0D .$14AC [85 0C ] STA $0C .$14AE [38 ] SEC ;TAKE THE NEGATIVE OF THE NUMBER OF PIXELS .$14AF [A9 00 ] LDA #$00 ; TO PLOT AND EXIT .$14B1 [E5 12 ] SBC $12 ;É DON'T REMEMBER EXACTLY WHY É USE THE .$14B3 [85 12 ] STA $12 ; NEGATIVE; THERE IS NOT MUCH OF A SPEED .$14B5 [A9 00 ] LDA #$00 ; IMPROVEMENT. ÏH WELL, T'IS DONE. .$14B7 [E5 13 ] SBC $13 .$14B9 [85 13 ] STA $13 .$14BB [60 ] RTS .$14BC [A5 FC ] LDA $FC ;SET THE PIXELS-TO-PLOT COUNT TO ÁÂÓ(ÄÙ) .$14BE [85 12 ] STA $12 .$14C0 [85 50 ] STA $50 .$14C2 [A5 FD ] LDA $FD .$14C4 [85 13 ] STA $13 .$14C6 [85 51 ] STA $51 ;SET THE NUMERATOR (TOP) TO ÄØ AND THE .$14C8 [A5 FA ] LDA $FA ; DENOMINATOR(BOTTOM) TO ÁÂÓ(ÄÙ) .$14CA [85 62 ] STA $62 .$14CC [A5 FB ] LDA $FB .$14CE [85 63 ] STA $63 .$14D0 [A5 0D ] LDA $0D ;GET THE SIGN OF ÄØ - WILL BE THE SIGN OF DIV .$14D2 [20 31 14] JSR $1431 ;DO THE 32-BIT SIGNED FRACTIONAL DIVISION .$14D5 [A2 03 ] LDX #$03 ;STORE THE RESULT IN THE Ø INCREMENT .$14D7 [B5 64 ] LDA $64,X .$14D9 [95 0A ] STA $0A,X .$14DB [CA ] DEX .$14DC [10 F9 ] BPL $14D7 .$14DE [4C EA 14] JMP $14EA ;JUMP OVER THE NEXT SECTION ;------- .$14E1 [2C FF FF] BIT $FFFF ;ÔHIS SECTION CONTAINED JUNK BEFORE AND É .$14E4 [2C FF FF] BIT $FFFF ; DON'T KNOW HOW IT GOT HERE. É REPLACED .$14E7 [2C FF FF] BIT $FFFF ; IT WITH ÂÉÔS AND NOW JUMP OVER IT. ;------- .$14EA [A5 11 ] LDA $11 .$14EC [30 0A ] BMI $14F8 .$14EE [A9 00 ] LDA #$00 ;IF ÄÙ IS POSITIVE THEN Ù INC IS +1 .$14F0 [85 11 ] STA $11 ; (WE DO NOT HAVE TO WORRY ABOUT THE CASE .$14F2 [A9 01 ] LDA #$01 ; OF ÄÙ BEING ZERO SINCE THEN THE INCREMENT .$14F4 [85 10 ] STA $10 ; WOULD NOT BE IMPORTANT) .$14F6 [D0 06 ] BNE $14FE .$14F8 [A9 FF ] LDA #$FF ;IF ÄÙ IS NEGATIVE THEN Ù INC IS -1 .$14FA [85 11 ] STA $11 .$14FC [85 10 ] STA $10 .$14FE [4C AE 14] JMP $14AE ;JUMP BACK TO THE EXIT ;***************************************************************************** ;* MAIN ROUTINE: DRAW LINE OR SET PIXEL CURSOR POSITION * ;***************************************************************************** .$1501 [B0 07 ] BCS $150A ;GOTO DRAW ROUTINE IF .Ã=1 .$1503 [85 8B ] STA $8B ;STORE X AND Y PIXEL CURSOR COORDINATES .$1505 [86 8C ] STX $8C .$1507 [84 8D ] STY $8D .$1509 [60 ] RTS ;EXIT SET PIXEL CURSOR .$150A [85 04 ] STA $04 ;SAVE DRAW-TO COORDINATES .$150C [86 05 ] STX $05 .$150E [84 08 ] STY $08 .$1510 [A2 07 ] LDX #$07 ;CLEAR $0A-$0D AND $0E-$11 .$1512 [A9 00 ] LDA #$00 .$1514 [95 0A ] STA $0A,X .$1516 [CA ] DEX .$1517 [10 FB ] BPL $1514 .$1519 [38 ] SEC ;GET DX VALUE = ÄRAWÔOØ - ÐIXELÃURSORØ .$151A [A5 04 ] LDA $04 ; DX IS AT [$0D $0C . $0B $0A] .$151C [E5 8B ] SBC $8B .$151E [85 0C ] STA $0C .$1520 [A5 05 ] LDA $05 .$1522 [E5 8C ] SBC $8C .$1524 [85 0D ] STA $0D .$1526 [38 ] SEC ;GET DY VALUE = ÄRAWÔOÙ - ÐIXELÃURSORÙ .$1527 [A5 08 ] LDA $08 ; DY IS AT [$11 $10 . $0F $0E] .$1529 [E5 8D ] SBC $8D .$152B [85 10 ] STA $10 .$152D [A9 00 ] LDA #$00 .$152F [B0 02 ] BCS $1533 .$1531 [A9 FF ] LDA #$FF .$1533 [85 11 ] STA $11 .$1535 [20 58 14] JSR $1458 ;CALCULATE THE Ø AND Ù PLOTTING INCREMENTS .$1538 [A5 8B ] LDA $8B ;SET THE DRAWING Ø POSITION TO X+0.5 .$153A [85 04 ] STA $04 ; Ø IS AT [$05 $04 . $03 $02] .$153C [A5 8C ] LDA $8C .$153E [85 05 ] STA $05 .$1540 [A9 80 ] LDA #$80 .$1542 [85 03 ] STA $03 .$1544 [85 07 ] STA $07 .$1546 [A9 00 ] LDA #$00 .$1548 [85 02 ] STA $02 .$154A [85 06 ] STA $06 .$154C [A5 8D ] LDA $8D ;SET THE DRAWING Ù POSITION TO Y+0.5 .$154E [85 08 ] STA $08 ; Ù IS AT [$09 $08 . $07 $06] .$1550 [A9 00 ] LDA #$00 .$1552 [85 09 ] STA $09 .$1554 [A5 04 ] LDA $04 ;GET THE PIXEL Ø AND Ù COORDINATES .$1556 [A6 05 ] LDX $05 .$1558 [A4 08 ] LDY $08 .$155A [20 A8 13] JSR $13A8 ;PLOT THE PIXEL .$155D [A5 12 ] LDA $12 ;CHECK THE PIXELS-TO-PLOT COUNT FOR ZERO .$155F [05 13 ] ORA $13 .$1561 [F0 3B ] BEQ $159E ;IF NO MORE PIXELS TO PLOT, EXIT LOOP .$1563 [18 ] CLC ;ADD THE Ø INCREMENT TO THE Ø COORDINATE .$1564 [A5 02 ] LDA $02 .$1566 [65 0A ] ADC $0A .$1568 [85 02 ] STA $02 .$156A [A5 03 ] LDA $03 .$156C [65 0B ] ADC $0B .$156E [85 03 ] STA $03 .$1570 [A5 04 ] LDA $04 .$1572 [65 0C ] ADC $0C .$1574 [85 04 ] STA $04 .$1576 [A5 05 ] LDA $05 .$1578 [65 0D ] ADC $0D .$157A [85 05 ] STA $05 .$157C [18 ] CLC ;ADD THE Ù INCREMENT TO THE Ù COORDINATE .$157D [A5 06 ] LDA $06 .$157F [65 0E ] ADC $0E .$1581 [85 06 ] STA $06 .$1583 [A5 07 ] LDA $07 .$1585 [65 0F ] ADC $0F .$1587 [85 07 ] STA $07 .$1589 [A5 08 ] LDA $08 .$158B [65 10 ] ADC $10 .$158D [85 08 ] STA $08 .$158F [A5 09 ] LDA $09 .$1591 [65 11 ] ADC $11 .$1593 [85 09 ] STA $09 .$1595 [E6 12 ] INC $12 ;INCREMENT THE PIXELS TO PLOT COUNT .$1597 [D0 BB ] BNE $1554 ; NOTE THAT IT IS STORED AS THE NEGATIVE OF .$1599 [E6 13 ] INC $13 ; THE COUNT .$159B [4C 54 15] JMP $1554 ;REPEAT PLOTTING LOOP .$159E [A5 04 ] LDA $04 ;EXIT - SET THE PIXEL CURSOR POSITION TO THE .$15A0 [A6 05 ] LDX $05 ; LAST PIXEL PLOTTED ON THE LINE .$15A2 [A4 08 ] LDY $08 .$15A4 [4C 03 15] JMP $1503